Setting session data and conditional redirect on login
What I want to do, is when a user logs in, pull a UserType value from the Users table, put that value in a session, and redirect the user, depending on $_SESSION[userType].
So, an 'admin' userType would go to one page/route, while a 'guest' userType would go to a different page/route.
would I do something like this in AuthenticatesUsers.php->login()? to pre-empt the "protected $redirectPath =.." ?
You can override the authenticated trait in your AuthController.php. Add something like this. This is lifted straight from one of my projects. You can see how the user object is passed through. You can redirect wherever you want after authentication.
public function authenticated($request, $user )
{
session(['customerId' => $user->customer_id]);
return redirect()->intended($this->redirectPath());
}
for some reason I couldn't get a value $user->user_id, I could only get $user->email and $user->password ... was there a better way to get the value of role_id ?