diff --git a/app/Http/Controllers/Auth/EmailVerificationController.php b/app/Http/Controllers/Auth/EmailVerificationController.php new file mode 100755 index 0000000..6108abe --- /dev/null +++ b/app/Http/Controllers/Auth/EmailVerificationController.php @@ -0,0 +1,19 @@ +user()->sendEmailVerificationNotification(); + + return back()->with('status', 'verification-link-sent'); + } +} diff --git a/app/Http/Controllers/Auth/LoginRedirectController.php b/app/Http/Controllers/Auth/LoginRedirectController.php new file mode 100755 index 0000000..ca0f6ac --- /dev/null +++ b/app/Http/Controllers/Auth/LoginRedirectController.php @@ -0,0 +1,16 @@ +logout(); + Session::invalidate(); + Session::regenerateToken(); + + return redirect('/'); + } +} diff --git a/app/Http/Controllers/Auth/TwoFactorChallengeController.php b/app/Http/Controllers/Auth/TwoFactorChallengeController.php new file mode 100755 index 0000000..c4ddf79 --- /dev/null +++ b/app/Http/Controllers/Auth/TwoFactorChallengeController.php @@ -0,0 +1,16 @@ +string('password', 255)->change(); + }); + } + + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->string('password', 60)->change(); + }); + } +}; diff --git a/routes/auth.php b/routes/auth.php index de85e0c..d18f9fe 100755 --- a/routes/auth.php +++ b/routes/auth.php @@ -1,6 +1,8 @@ group(function () { }); // Two factor challenge login -Route::get('/two-factor-challenge', static fn () => view('auth.two-factor-challenge'))->name('two-factor.login'); +Route::get('/two-factor-challenge', TwoFactorChallengeController::class)->name('two-factor.login'); // Email verification resend -Route::post('/email/verification-notification', static function () { - request()->user()->sendEmailVerificationNotification(); - - return back()->with('status', 'verification-link-sent'); -})->middleware(['auth', 'throttle:6,1'])->name('verification.send'); +Route::post('/email/verification-notification', EmailVerificationController::class) + ->middleware(['auth', 'throttle:6,1'])->name('verification.send'); // Two factor challenge with throttle if (Features::enabled(Features::twoFactorAuthentication())) { diff --git a/routes/web.php b/routes/web.php index 8dbdec5..0e657a6 100755 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,7 @@ group(functi // Home routes (guest only) Route::middleware(['guest', 'throttle:60,1'])->withoutMiddleware('force.staff.2fa')->group(function () { - Route::get('/login', static fn () => to_route('welcome'))->name('login'); + Route::get('/login', LoginRedirectController::class)->name('login'); Route::get('/', HomeController::class)->name('welcome'); Route::get('/home', HomeController::class)->name('home'); }); // Logout route - Route::post('/logout', static function () { - auth()->guard('web')->logout(); - session()->invalidate(); - session()->regenerateToken(); - - return redirect('/'); - })->name('logout'); + Route::post('/logout', LogoutController::class)->name('logout'); // Authenticated routes Route::middleware('auth')->group(function () {