Skip to content

Commit

Permalink
Rename POST routes (#573)
Browse files Browse the repository at this point in the history
Fix breaking change for users that use the names of the affected routes in their own route definitions.

Remove unnecessary conditions.
  • Loading branch information
cima-alfa authored Oct 28, 2024
1 parent 13bd031 commit 094c2eb
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions routes/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@
$twoFactorLimiter = config('fortify.limiters.two-factor');
$verificationLimiter = config('fortify.limiters.verification', '6,1');

$login = Route::post(RoutePath::for('login', '/login'), [AuthenticatedSessionController::class, 'store'])
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');
}
]))
->name('login.store');

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

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

if (! $enableViews) {
$register->name('register');
}
Route::post(RoutePath::for('register', '/register'), [RegisteredUserController::class, 'store'])
->middleware(['guest:'.config('fortify.guard')])
->name('register.store');
}

// Email Verification...
Expand Down Expand Up @@ -128,12 +122,9 @@
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
->name('password.confirmation');

$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');
}
Route::post(RoutePath::for('password.confirm', '/user/confirm-password'), [ConfirmablePasswordController::class, 'store'])
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
->name('password.confirm.store');

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

$twoFactorLogin = Route::post(RoutePath::for('two-factor.login', '/two-factor-challenge'), [TwoFactorAuthenticatedSessionController::class, 'store'])
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');
}
]))
->name('two-factor.login.store');

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

0 comments on commit 094c2eb

Please sign in to comment.