diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php new file mode 100644 index 0000000..4c69f42 --- /dev/null +++ b/app/Http/Controllers/AuthController.php @@ -0,0 +1,48 @@ +session()->token(); + + //$token = csrf_token(); + return view('front.login'); + } + + public function memberAuth(Request $request): Response + { + $token = csrf_token(); + + $credentials = $request->validate([ + 'handle' => ['required'], + 'password' => ['required'], + ]); + + if (Auth::attempt($credentials)) { + $request->session()->regenerate(); + return redirect()->intended('den'); + } + + return back()->withErrors([ + 'error' => 'Nope. Check your crendtials, champ', + ]); + } + + public function leave(Request $request): Response + { + Auth::logout(); + + $request->session()->invalidate(); + + $request->session()->regenerateToken(); + + return redirect()->intended('login'); + } +} diff --git a/app/Http/Controllers/DenController.php b/app/Http/Controllers/DenController.php new file mode 100644 index 0000000..22a3eee --- /dev/null +++ b/app/Http/Controllers/DenController.php @@ -0,0 +1,16 @@ + $member->handle]); + } +} diff --git a/app/Http/Controllers/FrontIndexController.php b/app/Http/Controllers/FrontIndexController.php index 8b7399d..652ebb8 100644 --- a/app/Http/Controllers/FrontIndexController.php +++ b/app/Http/Controllers/FrontIndexController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use Illuminate\Support\Facades\DB; use App\Models\Location; class FrontIndexController extends Controller @@ -11,6 +12,10 @@ class FrontIndexController extends Controller $locations = Location::all(); $count = count($locations); + $terms = "no|agenda"; + + //$result = DB::select("SELECT * FROM searchlocations('$terms')"); + return view('front.index', ['count' => $count]); } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 494c050..e21792f 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -36,11 +36,12 @@ class Kernel extends HttpKernel \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], '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 +54,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..8c70b10 --- /dev/null +++ b/app/Http/Middleware/MemberCheck.php @@ -0,0 +1,24 @@ + [ - 'guard' => 'web', - 'passwords' => 'users', + 'guard' => 'web', + 'passwords' => 'member', ], /* @@ -37,8 +37,8 @@ return [ 'guards' => [ 'web' => [ - 'driver' => 'session', - 'provider' => 'users', + 'driver' => 'session', + 'provider' => 'member', ], ], @@ -60,9 +60,9 @@ return [ */ 'providers' => [ - 'users' => [ + 'member' => [ 'driver' => 'eloquent', - 'model' => App\Models\User::class, + 'model' => App\Models\Member::class, ], // 'users' => [ @@ -91,10 +91,10 @@ return [ */ 'passwords' => [ - 'users' => [ - 'provider' => 'users', - 'table' => 'password_reset_tokens', - 'expire' => 60, + 'member' => [ + 'provider' => 'member', + 'table' => 'password_reset_tokens', + 'expire' => 60, 'throttle' => 60, ], ], diff --git a/resources/views/back/start.blade.php b/resources/views/back/start.blade.php new file mode 100644 index 0000000..01e47d5 --- /dev/null +++ b/resources/views/back/start.blade.php @@ -0,0 +1,11 @@ +@extends('frame') + +@section('title', 'Den|Start') + + @section('main-content') + +
+

The Den

+ Hey {{$handle}} +
+ @endsection \ No newline at end of file diff --git a/resources/views/front/login.blade.php b/resources/views/front/login.blade.php new file mode 100644 index 0000000..b1ba1cf --- /dev/null +++ b/resources/views/front/login.blade.php @@ -0,0 +1,21 @@ +@extends('frame') + +@section('title', 'Login') + + @section('main-content') + @parent + @if($errors->any()) +

{{$errors->first()}}

+ @endif +
+
+ @csrf +
+ +
+
+ + +
+
+ @endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index a8edffa..d361360 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,6 +2,8 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\FrontIndexController; +use App\Http\Controllers\AuthController; +use App\Http\Controllers\DenController; /* |-------------------------------------------------------------------------- @@ -14,4 +16,13 @@ use App\Http\Controllers\FrontIndexController; | */ +//index Route::get("/", [FrontIndexController::class, 'start']); + +//auth +Route::get("/login", [AuthController::class, 'showLogin']); +Route::post("/login", [AuthController::class, 'memberAuth']); + +//den +Route::get("/den", [DenController::class, 'start'])->middleware('member.check'); +Route::get("/logout", [AuthController::class, 'leave']);