302 Found after creating laravel auth guard for user page

34 views Asked by At

Currently the system shared the same session as the admin and the user, so an admin and user account can't login at the same on the same browser.

To do that, we added an auth guard on backend side just for the user. On the function named userLogin

From this,

Auth::login($user, $remember);

To this,

Auth::guard('user')->attempt([
  'email' => $email,
  'password' => $input['password']
]);

adding this to auth.php file

'user'=>[
   'driver'=>'session',
   'provider'=>'users'
]

and on the function where we need to check if the student is logged in, we update this,

$user = Auth::guard('sanctum')->user();

to this,

$user = Auth::guard('user')->user();

Is there anything needed to update on frontend side? Since after this update, admin side is fine, admin is using /login route for logging in. It is the user where when they logged in user login page (/users/login), it navigates to dashboard page with no problem. But when they refresh or reload the page, it returns a 302 Found and redirects to admin login page (/login) instead of staying in the same url.

We are using angular and laravel for this project.

I tried debugging where this 302 found coming from, since auth guard on the frontend side is activated properly.

0

There are 0 answers