1

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 ?

11
  • show your middleware?? Commented Feb 14, 2018 at 12:11
  • It's funny I wrote an article on access control just two days ago kerneldev.com/2018/02/12/… You might want to check it out :) Commented Feb 14, 2018 at 12:11
  • can you show your middleware Commented Feb 14, 2018 at 12:12
  • @sohel0415 The middleware auth is the built-in middleware of laravel. I haven't wrote it ! Commented Feb 14, 2018 at 12:13
  • @sibasankarBhoi The middleware auth is the built-in middleware of laravel. I haven't wrote it ! Commented Feb 14, 2018 at 12:14

1 Answer 1

0

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'); }); 
Sign up to request clarification or add additional context in comments.

2 Comments

Done ! Now when i want to go to admin login its redirects me to the users login page !
Please see this github repo. i think it will help your problem.. github.com/rahmanmajeed/MultiAuthDev

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.