Skip to content

Commit 5bd3bdd

Browse files
Rename POST routes to avoid regression bugs (#574)
* 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 <[email protected]>
1 parent 13bd031 commit 5bd3bdd

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

routes/routes.php

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@
3535
$twoFactorLimiter = config('fortify.limiters.two-factor');
3636
$verificationLimiter = config('fortify.limiters.verification', '6,1');
3737

38-
$login = Route::post(RoutePath::for('login', '/login'), [AuthenticatedSessionController::class, 'store'])
38+
Route::post(RoutePath::for('login', '/login'), [AuthenticatedSessionController::class, 'store'])
3939
->middleware(array_filter([
4040
'guest:'.config('fortify.guard'),
4141
$limiter ? 'throttle:'.$limiter : null,
42-
]));
43-
44-
if (! $enableViews) {
45-
$login->name('login');
46-
}
42+
]))->name('login.store');
4743

4844
Route::post(RoutePath::for('logout', '/logout'), [AuthenticatedSessionController::class, 'destroy'])
4945
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
@@ -78,12 +74,9 @@
7874
->name('register');
7975
}
8076

81-
$register = Route::post(RoutePath::for('register', '/register'), [RegisteredUserController::class, 'store'])
82-
->middleware(['guest:'.config('fortify.guard')]);
83-
84-
if (! $enableViews) {
85-
$register->name('register');
86-
}
77+
Route::post(RoutePath::for('register', '/register'), [RegisteredUserController::class, 'store'])
78+
->middleware(['guest:'.config('fortify.guard')])
79+
->name('register.store');
8780
}
8881

8982
// Email Verification...
@@ -128,12 +121,9 @@
128121
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
129122
->name('password.confirmation');
130123

131-
$passwordConfirm = Route::post(RoutePath::for('password.confirm', '/user/confirm-password'), [ConfirmablePasswordController::class, 'store'])
132-
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]);
133-
134-
if (! $enableViews) {
135-
$passwordConfirm->name('password.confirm');
136-
}
124+
Route::post(RoutePath::for('password.confirm', '/user/confirm-password'), [ConfirmablePasswordController::class, 'store'])
125+
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
126+
->name('password.confirm.store');
137127

138128
// Two Factor Authentication...
139129
if (Features::enabled(Features::twoFactorAuthentication())) {
@@ -143,15 +133,11 @@
143133
->name('two-factor.login');
144134
}
145135

146-
$twoFactorLogin = Route::post(RoutePath::for('two-factor.login', '/two-factor-challenge'), [TwoFactorAuthenticatedSessionController::class, 'store'])
136+
Route::post(RoutePath::for('two-factor.login', '/two-factor-challenge'), [TwoFactorAuthenticatedSessionController::class, 'store'])
147137
->middleware(array_filter([
148138
'guest:'.config('fortify.guard'),
149139
$twoFactorLimiter ? 'throttle:'.$twoFactorLimiter : null,
150-
]));
151-
152-
if (! $enableViews) {
153-
$twoFactorLogin->name('two-factor.login');
154-
}
140+
]))->name('two-factor.login.store');
155141

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

0 commit comments

Comments
 (0)