You need to make your own guard. It means your session will have 2 type of auth users at same time. https://laravel.com/docs/5.4/authentication#authenticating-users https://laravel.com/docs/5.4/authentication#adding-custom-guards Or this video can solve your problem https://www.youtube.com/watch?v=iKRLrJXNN4M
Multiple user login, with same table but with different roles.
I have a base table users, which supports 2 different types of users: admin and client. I am using Zicaco Entrust package for role management.
I need different login for the admin and the client user types. Both of the users should be able to login in the system at the same time. I am unable to think what to do next.
What can be the solution for this ?
@Agelios I followed the documentation, i created a new guard by adding it in the config/auth:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'clients' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'front' => [
'driver' => 'session',
'provider' => 'clients',
],
Now, i do have a controller: Front/Auth/loginController:
if ($this->guard()->attempt(['email' => $request->email, 'password' => $request->password, 'active' => 1])) {
dd(' i am logged in');
}
}
/**
* Front is the guard for front.
* @return mixed
*/
protected function guard()
{
return auth()->guard('front');
}
So if I login from the backend i.e (/admin/login) and refresh here at the front, i am getting CSRF invalid message. I think this is because of session. But don't know how to solve it. Please help me. I want both of the logins at the same time.
Please or to participate in this conversation.