Skip to content

Commit 0e9c9ec

Browse files
authored
Fix unnamed routes when views are disabled (with original code formatting) (#571)
* Fix unnamed routes when views are disabled * Fix unnamed routed when views are disabled * Run pint * Revert formatting
1 parent 6516ff9 commit 0e9c9ec

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

routes/routes.php

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

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

44+
if (! $enableViews) {
45+
$login->name('login');
46+
}
47+
4448
Route::post(RoutePath::for('logout', '/logout'), [AuthenticatedSessionController::class, 'destroy'])
4549
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
4650
->name('logout');
@@ -74,8 +78,12 @@
7478
->name('register');
7579
}
7680

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

8189
// Email Verification...
@@ -112,16 +120,20 @@
112120
// Password Confirmation...
113121
if ($enableViews) {
114122
Route::get(RoutePath::for('password.confirm', '/user/confirm-password'), [ConfirmablePasswordController::class, 'show'])
115-
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]);
123+
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
124+
->name('password.confirm');
116125
}
117126

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

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

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

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

152+
if (! $enableViews) {
153+
$twoFactorLogin->name('two-factor.login');
154+
}
155+
140156
$twoFactorMiddleware = Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword')
141157
? [config('fortify.auth_middleware', 'auth').':'.config('fortify.guard'), 'password.confirm']
142158
: [config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')];

0 commit comments

Comments
 (0)