Multiple panel login
I have three types of user namely
1. admin
2. agent
3. merchant
I create multiple panel like
/admin
, /agent
and /merchant
I want the users
who have user_type = agent
only can login in /agent
and so on, so
1. Do I need to create multiple custom login page (custom) for each different user_type
2. Can I create one login page (custom) and check base on user_type
, if so, how can I know user_type = agent
is trying to login using /agent
only and block (throw error) if trying to login in /admin
and so on
Thanks in advance13 Replies
Do I need to create multiple custom login page (custom) for each different user_typeYou need multiple auth guards which you can set on the panel
->authGuard()
. Check Laravel docs and your config/auth.php
file.
Can I create one login page (custom) and check base on user_type, if so, how can I know user_type = agent is trying to login using /agent only and block (throw error) if trying to login in /admin and so onYou probably can create your own login page, disable all the logins on the panels, and redirect on user type.
Okay, understood.. thanks
For the second you can just add your own loginresponse
And make checks there
Yeah right. Good call.
Or just adapt
canAccessPanel()
in the user model and check for panel ID and user_type (that's how I do it)Instead of auth guards? Yeah might be the easier way.
Yep 🙂 guards work too, but might be a bit overkill? Geschmacksfrage I guess 😉
yeah
canAccessPanel()
would be easierMay you kindly share a code example of this?
ain't even trying🤦♂️
I did it like this:
I hope you verify those emailadresses 😅