Use Single Login Route For Multiple Panels
I'm using multiple panels in my Filament app, but each panel has its own login page.
I want a single login page at
domain/login
, and after authentication, users should be redirected to their respective panel based on their role.
Example:
Instead of separate login pages for each panel:
admin/login
group/login
I want a unified login page at domain/login
for all users. After login:
A user with the admin-user
role should be redirected to the AdminPanel.
A user with the group-user
role should be redirected to the GroupPanel.
How can I achieve this?3 Replies
Filament Daily
YouTube
Filament: Same Login Form for Multiple Panels
One of the approaches to auto-redirect the user and disable the other login page.
Original text-based tutorial: https://filamentexamples.com/tutorial/multiple-panels-sign-in-via-one-sign-in-page
Actually i want a URL like
domain/login
and if i login in with credentials which has role admin-user
should be redirected to the domain/admin
and similarly for the group panel.
How I did :
I created another Panel called LoginPanel and used the above provided video reference for multi panel single login and i made the LoginPanel as default.
Below i provided the code for reference:
Login Panel:
Admin Panel:
Group Panel:
RoutesAccessMiddleware:
LoginResponse:
LogoutResponse:
Everything is working as expected but the issue i am facing is that when the user is logged in as any role suppose as admin-user
and in domain/admin
and if i change the URL to domain/login
then it is redirected to domain
.
What i want is if logged in any user tries to access the domain/login
then it should redirect to their respective panel dashboard.i hope, this article can help you https://filamentexamples.com/tutorial/multiple-panels-sign-in-via-one-sign-in-page
Filament Examples
Filament Multiple Panels: Single Login Page for Admin/User Roles
Having multiple panels is excellent for separating users from other roles. However, managing each different login page can be tricky. So, let's make one login page for all panels and switch redirects based on roles.