Skip to content
Discussion options

You must be logged in to vote

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 Route::middleware('auth:admin') instead of custom Route::middleware('admin')
solves the problem.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@andrekutianski
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by liepumartins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants