-1

I am using Multiple Authentication in laravel 5.4. Here I have two controller for login. One is for normal user and other is for admin. Both controller is restricted by guest middleware. Because of using this guest controller is if a person is logged in as admin or user he must not to get any log in page. But this guest middleware only work when I log in using UserController. I mean if I log in using user controller then try to go to the log in page or admin page it redirect me to user dashboard page. That is ok. But when I log in using AdminLoginController then try to log in as user or log in again as admin it allow me to log in again. I have used this construct function in both controller.

public function __construct()
{
    $this->middleware('guest');

}

Help me please.

this question can't solved my problem. Because I have downloaded code from that solution and I still got this error. That logged in admin can visit user log in form. This error also have in this answer.

Fokrule
  • 844
  • 2
  • 11
  • 30
  • Possible duplicate of [Can anyone explain Laravel 5.2 Multi Auth with example](https://stackoverflow.com/questions/34614753/can-anyone-explain-laravel-5-2-multi-auth-with-example) – Nitish Kumar Sep 24 '17 at 18:45
  • My problem is difference. I have done everything nicely. And everything is working fine. Just `guest` 'middleware is not working for `AdminLoginController`. I just want to know how I can make it work. – Fokrule Sep 24 '17 at 20:16

1 Answers1

0

Restrict them with the auth middleware:

public function __construct()
{
    $this->middleware('auth');

}

https://laravel.com/docs/5.5/authentication#protecting-routes

jeremykenedy
  • 4,150
  • 1
  • 17
  • 25