Support for auth guards is broken in the routes file
MtDalPizzol opened this issue · comments
- Fortify Version: 1.7.14
- Laravel Version: 8.40.x
- PHP Version: 7.4.x
Description:
Using custom guards is broken in the routes.php file. Found it when trying to use Fortify on two endpoints with a different guard for each one. When dealing with the admin
guard, it was causing the user to be redirected to the login page when doing things like trying to enable 2fa.
Steps To Reproduce:
If we define a guard like "admin" and set it with config(['fortify.guard' => 'admin'])
, it is not being used in the routes.php file. I think that where we're using the 'auth'
middlewhere it should be 'auth:' . config('fortify.guard')
. For example:
// Email Verification...
if (Features::enabled(Features::emailVerification())) {
if ($enableViews) {
Route::get('/email/verify', [EmailVerificationPromptController::class, '__invoke'])
->middleware(['auth']) // ->middleware(['auth:' . config('fortify.guard')])
->name('verification.notice');
}
Route::get('/email/verify/{id}/{hash}', [VerifyEmailController::class, '__invoke'])
->middleware(['auth', 'signed', 'throttle:6,1']) // ->middleware(['auth:' . config('fortify.guard'), 'signed', 'throttle:6,1'])
->name('verification.verify');
Route::post('/email/verification-notification', [EmailVerificationNotificationController::class, 'store'])
->middleware(['auth', 'throttle:6,1']) // ->middleware(['auth:' . config('fortify.guard'), 'throttle:6,1'])
->name('verification.send');
}