Two panels (User and Admin), with shared login page and session
Now that you can have more than one panel, I'm trying to have two panels:
- Main (with no path, so on /) with authentication (and default).
- Admin (/admin) with authentication.
Is it possible to share the login between the two panels? Meaning that both panels use the login form on /login and after login in there, you can access both panels (if your role allows it, which I don't know yet how I will restrict).
I was planning to use the #bezhansalleh-panel-switch plugin, so if you are an admin, you'll see the action there to switch between both panels, without needing to authenticate again. If you are a user, no switch action should even appear.
15 Replies
Correct me if I'm wrong, but doesn't filament already have that ability? I have written a tutorial about multi-panels and simply just switched url - that worked just fine. The key aspect was to prevent access for simple users and that's it
And you can even add the automatic redirect from both logins if needed:
(A bit of an plug that's not intentional, but that's exactly what I've written so...)
https://laraveldaily.com/post/filament-disable-dashboard-auto-redirect-url-after-login
Hey, thanks for the reply!
Seems you are right. The session is already shared apparently, so when you login in /login or /admin/login (in my case) you already can access any panel you have permissions on.
I could leave it like that or make a redirect to use /login on both I guess.
Yeah, or just allow both to log in, but then use the same back-end to handle the redirects π
Well, that in my case already happens, since I have a custom Login page that only has a button to redirect to the OIDC provider which sends the callback to /auth/callback anyway, so maybe I'm trying to complicate things too much π
Most likely in that case π
Or redirect using login response
@krekas Heh, you added exactly the same link π
lol
I ended up solving the redirect thingy a bit diferently
π
Since I have a custom Login page that both panels use I added to the mount method:
So any other panel than the main one, when going to their /X/login redirects to /login
That works also π in the article you could've checked for the panel ID that user just came from, which would do the same
yeah, that too, but I prefer to avoid adding the LoginResponse if I don't need it for anything else (for now...)
Yeah, it makes sense!