Skip to content

Commit

Permalink
Fix unnamed routes when views are disabled (with original code format…
Browse files Browse the repository at this point in the history
…ting) (#571)

* Fix unnamed routes when views are disabled

* Fix unnamed routed when views are disabled

* Run pint

* Revert formatting
  • Loading branch information
cima-alfa authored Oct 18, 2024
1 parent 6516ff9 commit 0e9c9ec
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions routes/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@
$twoFactorLimiter = config('fortify.limiters.two-factor');
$verificationLimiter = config('fortify.limiters.verification', '6,1');

Route::post(RoutePath::for('login', '/login'), [AuthenticatedSessionController::class, 'store'])
$login = Route::post(RoutePath::for('login', '/login'), [AuthenticatedSessionController::class, 'store'])
->middleware(array_filter([
'guest:'.config('fortify.guard'),
$limiter ? 'throttle:'.$limiter : null,
]));

if (! $enableViews) {
$login->name('login');
}

Route::post(RoutePath::for('logout', '/logout'), [AuthenticatedSessionController::class, 'destroy'])
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
->name('logout');
Expand Down Expand Up @@ -74,8 +78,12 @@
->name('register');
}

Route::post(RoutePath::for('register', '/register'), [RegisteredUserController::class, 'store'])
$register = Route::post(RoutePath::for('register', '/register'), [RegisteredUserController::class, 'store'])
->middleware(['guest:'.config('fortify.guard')]);

if (! $enableViews) {
$register->name('register');
}
}

// Email Verification...
Expand Down Expand Up @@ -112,16 +120,20 @@
// Password Confirmation...
if ($enableViews) {
Route::get(RoutePath::for('password.confirm', '/user/confirm-password'), [ConfirmablePasswordController::class, 'show'])
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]);
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
->name('password.confirm');
}

Route::get(RoutePath::for('password.confirmation', '/user/confirmed-password-status'), [ConfirmedPasswordStatusController::class, 'show'])
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
->name('password.confirmation');

Route::post(RoutePath::for('password.confirm', '/user/confirm-password'), [ConfirmablePasswordController::class, 'store'])
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
->name('password.confirm');
$passwordConfirm = Route::post(RoutePath::for('password.confirm', '/user/confirm-password'), [ConfirmablePasswordController::class, 'store'])
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]);

if (! $enableViews) {
$passwordConfirm->name('password.confirm');
}

// Two Factor Authentication...
if (Features::enabled(Features::twoFactorAuthentication())) {
Expand All @@ -131,12 +143,16 @@
->name('two-factor.login');
}

Route::post(RoutePath::for('two-factor.login', '/two-factor-challenge'), [TwoFactorAuthenticatedSessionController::class, 'store'])
$twoFactorLogin = Route::post(RoutePath::for('two-factor.login', '/two-factor-challenge'), [TwoFactorAuthenticatedSessionController::class, 'store'])
->middleware(array_filter([
'guest:'.config('fortify.guard'),
$twoFactorLimiter ? 'throttle:'.$twoFactorLimiter : null,
]));

if (! $enableViews) {
$twoFactorLogin->name('two-factor.login');
}

$twoFactorMiddleware = Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword')
? [config('fortify.auth_middleware', 'auth').':'.config('fortify.guard'), 'password.confirm']
: [config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')];
Expand Down

0 comments on commit 0e9c9ec

Please sign in to comment.