Passing guard name via middleware route #2105
-
I have the default I have a permission The admin User model has
If default in |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Maybe User has web and admin guard at the same time, so default guard is chosen laravel-permission/src/Guard.php Lines 74 to 86 in 8a69aad |
Beta Was this translation helpful? Give feedback.
-
I was implementing an admin middleware like this (as numerous suggestions and tutorials show): AdminMiddleware.php public function handle(Request $request, Closure $next): mixed
{
if (!Auth::guard('admin')->check()) {
return redirect()->route('admin.login');
}
return $next($request);
} app/Http/Kernel.php protected $routeMiddleware = [
'auth' => Authenticate::class,
'admin' => AdminMiddleware::class, However removing that and just using |
Beta Was this translation helpful? Give feedback.
I was implementing an admin middleware like this (as numerous suggestions and tutorials show):
AdminMiddleware.php
app/Http/Kernel.php
However removing that and just using
Route::middleware('auth:admin')
instead of customRoute::middleware('admin')
solves the problem.