Laravel multi auth | Route middleware

Gammer Source

I have to tables which i am authenticating with users, admins. I have changed the config/auth.php accordingly for guards and providers.

Now i have some guarded routes for admins like :

Route::group(['middleware' => ['auth']], function () {
    Route::get('/admin', '[email protected]')->name('adminIndex');

I am applying middleware auth on the above route, It kicks me back to the user login page(/login), Not to the admin dashboard page.

Why is that, What am i missing ?



answered 8 months ago Gabrielle #1

You Should mention the guards name along with the middleware.if you have an admin guards then define like below.

Please Try this, hope it will work

Route::group(['middleware' => ['auth:admin']], function () {
Route::get('/admin', '[email protected]')->name('adminIndex');

comments powered by Disqus