DEV Community

Discussion on: Multiple role-based authentication in Laravel

Collapse
 
boypanjaitan16 profile image
Boy Panjaitan

How if the user have multiple account with different roles,but with the same credentials ? I assumed this nice guide not covered it yet :)

Collapse
 
mrdionjr profile image
Salomon Dion • Edited

In that case, create a separate table for roles and permissions (spatie/laravel-permission can help). Then, create the permissions and roles and assign permissions to roles. I would recommend as best practice to rely mainly on permissions in your applications as differents roles may have common permissions. Now, when a user is created assign him a role, and rely on this first role for redirect ($user->roles()->id). You can have a menu where he can switch to another dashboard based on his roles. Hope it helps.

Collapse
 
kaperskyguru profile image
Solomon Eseme

Yes the article didn't cover that. But I will suggest you use OTP to implement such scenerios.