diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/Dash/AuthController.php similarity index 89% rename from app/Http/Controllers/AuthController.php rename to app/Http/Controllers/Dash/AuthController.php index 599b19f..ea333d9 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/Dash/AuthController.php @@ -1,8 +1,9 @@ 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'], diff --git a/app/Http/Controllers/DashController.php b/app/Http/Controllers/Dash/IndexController.php similarity index 80% rename from app/Http/Controllers/DashController.php rename to app/Http/Controllers/Dash/IndexController.php index bedbf59..66a64d3 100644 --- a/app/Http/Controllers/DashController.php +++ b/app/Http/Controllers/Dash/IndexController.php @@ -1,12 +1,13 @@ 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 = []; diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 494c050..1d5a3e9 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -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, ], ]; @@ -53,16 +53,17 @@ class Kernel extends HttpKernel * @var array */ protected $middlewareAliases = [ - 'auth' => \App\Http\Middleware\Authenticate::class, - 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, - 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, - 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, - 'can' => \Illuminate\Auth\Middleware\Authorize::class, - 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, - 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, - 'signed' => \App\Http\Middleware\ValidateSignature::class, - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, - 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, + '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, ]; } diff --git a/app/Http/Middleware/MemberCheck.php b/app/Http/Middleware/MemberCheck.php new file mode 100644 index 0000000..c68f1f2 --- /dev/null +++ b/app/Http/Middleware/MemberCheck.php @@ -0,0 +1,32 @@ +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'); + } + } +} diff --git a/resources/views/back/login.blade.php b/resources/views/back/login.blade.php new file mode 100644 index 0000000..a051f0e --- /dev/null +++ b/resources/views/back/login.blade.php @@ -0,0 +1,7 @@ +@extends('frame') + +@section('title', 'The Dash | Start') + + @section('main-content') + @include('forms.login') + @endsection diff --git a/resources/views/back/start.blade.php b/resources/views/back/start.blade.php index d28f800..6850f3f 100644 --- a/resources/views/back/start.blade.php +++ b/resources/views/back/start.blade.php @@ -3,9 +3,36 @@ @section('title', 'The Dash | Start') @section('main-content') - @if($status) - @include('includes.index') - @else - @include('forms.login') - @endif +
+
+

Recent

+
+
+
+
+ @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') + + @include('includes.recent-meta') + + + @else + + @include('includes.recent-meta') + + @endif + @endforeach + @endif +
+ @endsection diff --git a/resources/views/includes/index.blade.php b/resources/views/includes/index.blade.php deleted file mode 100644 index b1433fc..0000000 --- a/resources/views/includes/index.blade.php +++ /dev/null @@ -1,31 +0,0 @@ -
-
-

Recent

-
-
-
-
- @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') - - @include('includes.recent-meta') - - - @else - - @include('includes.recent-meta') - - @endif - @endforeach - @endif -
diff --git a/routes/web.php b/routes/web.php index e9d3031..bacd4e7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,8 +1,8 @@ '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']); });