reorganized controller dir, added check for dash
seperated dash controllers for api controllers in the controller directory to make them easier to manage also added middleware to check authorization when accessing dash pages
This commit is contained in:
parent
1e37580869
commit
f7c9558da2
8 changed files with 108 additions and 57 deletions
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Dash;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\AuthService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
@ -27,7 +28,7 @@ class AuthController extends Controller
|
|||
$result = $this->auth->check($request);
|
||||
if ($result['status']) {
|
||||
//$request->session()->regenerate();
|
||||
return redirect()->intended('dashboard');
|
||||
return redirect()->intended('dashboard/start');
|
||||
} else {
|
||||
return back()->withErrors([
|
||||
'error' => $result['message'],
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Dash;
|
||||
|
||||
use App\Interfaces\PageRepositoryInterface;
|
||||
use App\Services\AuthService;
|
||||
use App\Services\ThemeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class DashController extends Controller
|
||||
class IndexController extends Controller
|
||||
{
|
||||
protected PageRepositoryInterface $pages;
|
||||
protected AuthService $auth;
|
||||
|
@ -22,6 +23,18 @@ class DashController extends Controller
|
|||
$this->themes = $themeService;
|
||||
}
|
||||
|
||||
public function login()
|
||||
{
|
||||
if ($this->auth::status()) {
|
||||
return redirect('dashboard/start');
|
||||
} else {
|
||||
return view('back.login', [
|
||||
"status" => $this->auth::status(),
|
||||
"title" => "Hi!"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function start()
|
||||
{
|
||||
$result = [];
|
|
@ -40,7 +40,7 @@ class Kernel extends HttpKernel
|
|||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
@ -64,5 +64,6 @@ class Kernel extends HttpKernel
|
|||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'member.check' => \App\Http\Middleware\MemberCheck::class,
|
||||
];
|
||||
}
|
||||
|
|
32
app/Http/Middleware/MemberCheck.php
Normal file
32
app/Http/Middleware/MemberCheck.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\AuthService;
|
||||
|
||||
class MemberCheck
|
||||
{
|
||||
protected $auth;
|
||||
|
||||
public function __construct(
|
||||
AuthService $authService,
|
||||
) {
|
||||
$this->auth = $authService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if ($this->auth::status()) {
|
||||
return $next($request);
|
||||
} else {
|
||||
return redirect('dashboard');
|
||||
}
|
||||
}
|
||||
}
|
7
resources/views/back/login.blade.php
Normal file
7
resources/views/back/login.blade.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
@extends('frame')
|
||||
|
||||
@section('title', 'The Dash | Start')
|
||||
|
||||
@section('main-content')
|
||||
@include('forms.login')
|
||||
@endsection
|
|
@ -3,9 +3,36 @@
|
|||
@section('title', 'The Dash | Start')
|
||||
|
||||
@section('main-content')
|
||||
@if($status)
|
||||
@include('includes.index')
|
||||
<section class="index-header">
|
||||
<div class="index-header-left">
|
||||
<h1>Recent</h1>
|
||||
</div>
|
||||
<div class="index-header-right"></div>
|
||||
</section>
|
||||
<section class="index-recent-pages">
|
||||
@if($result['entryCount'] != 0)
|
||||
@foreach($result['pages'] as $page)
|
||||
@php
|
||||
$type = '';
|
||||
$file = '';
|
||||
isset($page['media'][0]['type']) ? $type = $page['media'][0]['type'] : $type = '';
|
||||
isset($page['media'][0]['file']) ? $file = $page['media'][0]['file'] : $file = '';
|
||||
@endphp
|
||||
@if($type =='mp4')
|
||||
<a href="/dashboard/page/edit/{{ $page['uuid'] }}" id="{{ $page['uuid'] }}" class="post-video-link recent-link">
|
||||
@include('includes.recent-meta')
|
||||
<video class="post-video" loop muted autoplay>
|
||||
<source src="{{ $file }}" type="video/mp4">
|
||||
Sorry, your browser doesn't support embedded videos.
|
||||
</video>
|
||||
</a>
|
||||
@else
|
||||
@include('forms.login')
|
||||
<a href="/dashboard/page/edit/{{ $page['uuid'] }}" id="{{ $page['uuid'] }}" class="post-link recent-link" style="background: url({{ $file }}) no-repeat center center / cover #fc6399">
|
||||
@include('includes.recent-meta')
|
||||
</a>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
</section>
|
||||
|
||||
@endsection
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<section class="index-header">
|
||||
<div class="index-header-left">
|
||||
<h1>Recent</h1>
|
||||
</div>
|
||||
<div class="index-header-right"></div>
|
||||
</section>
|
||||
<section class="index-recent-pages">
|
||||
@if($result['entryCount'] != 0)
|
||||
@foreach($result['pages'] as $page)
|
||||
@php
|
||||
$type = '';
|
||||
$file = '';
|
||||
isset($page['media'][0]['type']) ? $type = $page['media'][0]['type'] : $type = '';
|
||||
isset($page['media'][0]['file']) ? $file = $page['media'][0]['file'] : $file = '';
|
||||
@endphp
|
||||
@if($type =='mp4')
|
||||
<a href="/dashboard/page/edit/{{ $page['uuid'] }}" id="{{ $page['uuid'] }}" class="post-video-link recent-link">
|
||||
@include('includes.recent-meta')
|
||||
<video class="post-video" loop muted autoplay>
|
||||
<source src="{{ $file }}" type="video/mp4">
|
||||
Sorry, your browser doesn't support embedded videos.
|
||||
</video>
|
||||
</a>
|
||||
@else
|
||||
<a href="/dashboard/page/edit/{{ $page['uuid'] }}" id="{{ $page['uuid'] }}" class="post-link recent-link" style="background: url({{ $file }}) no-repeat center center / cover #fc6399">
|
||||
@include('includes.recent-meta')
|
||||
</a>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
</section>
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\DashController;
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\Http\Controllers\Dash\IndexController;
|
||||
use App\Http\Controllers\Dash\AuthController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -22,12 +22,13 @@ Route::get('/', function () {
|
|||
//DASHBOARD
|
||||
|
||||
//login stuff
|
||||
Route::get("/dashboard", [IndexController::class, 'login']);
|
||||
Route::post("/login", [AuthController::class, 'enter']);
|
||||
|
||||
//back
|
||||
Route::group(['prefix' => 'dashboard'], function () {
|
||||
Route::get("/", [DashController::class, 'start']);
|
||||
Route::get("/pages/{pageFilter?}/{pageNum?}", [DashController::class, 'book']);
|
||||
Route::get("/page/{mode}/{uuid}", [DashController::class, 'page']);
|
||||
Route::group(['prefix' => 'dashboard', 'middleware' => 'member.check'], function () {
|
||||
Route::get("/start", [IndexController::class, 'start'])->name('start');
|
||||
Route::get("/pages/{pageFilter?}/{pageNum?}", [IndexController::class, 'book']);
|
||||
Route::get("/page/{mode}/{uuid}", [IndexController::class, 'page']);
|
||||
Route::get("/logout", [AuthController::class, 'exit']);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue