Skip to content

Commit

Permalink
Rename POST routes to avoid regression bugs (#574)
Browse files Browse the repository at this point in the history
* Rename POST routes (#573)

Fix breaking change for users that use the names of the affected routes in their own route definitions.

Remove unnecessary conditions.

* Update routes.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
cima-alfa and taylorotwell authored Oct 29, 2024
1 parent 13bd031 commit 5bd3bdd
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions routes/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@
$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 +74,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 +121,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 +133,11 @@
->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 5bd3bdd

Please sign in to comment.