简体   繁体   中英

Laravel multi auth | Route middleware

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', 'AdminController@index')->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 ?

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', 'AdminController@index')->name('adminIndex');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM