F
Filamentβ€’15mo ago
RixzZ

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
ModestasV
ModestasVβ€’15mo ago
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
RixzZ
RixzZOPβ€’15mo ago
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.
ModestasV
ModestasVβ€’15mo ago
Yeah, or just allow both to log in, but then use the same back-end to handle the redirects πŸ˜„
RixzZ
RixzZOPβ€’15mo ago
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 πŸ˜…
ModestasV
ModestasVβ€’15mo ago
Most likely in that case πŸ™‚
krekas
krekasβ€’15mo ago
Or redirect using login response
ModestasV
ModestasVβ€’15mo ago
@krekas Heh, you added exactly the same link πŸ˜„
krekas
krekasβ€’15mo ago
lol
RixzZ
RixzZOPβ€’15mo ago
I ended up solving the redirect thingy a bit diferently
ModestasV
ModestasVβ€’15mo ago
πŸ‘
RixzZ
RixzZOPβ€’15mo ago
Since I have a custom Login page that both panels use I added to the mount method:
if (request()->path() !== 'login') {
redirect()->route('filament.main.auth.login');
}
if (request()->path() !== 'login') {
redirect()->route('filament.main.auth.login');
}
So any other panel than the main one, when going to their /X/login redirects to /login
ModestasV
ModestasVβ€’15mo ago
That works also πŸ™‚ in the article you could've checked for the panel ID that user just came from, which would do the same
RixzZ
RixzZOPβ€’15mo ago
yeah, that too, but I prefer to avoid adding the LoginResponse if I don't need it for anything else (for now...)
ModestasV
ModestasVβ€’15mo ago
Yeah, it makes sense!
Want results from more Discord servers?
Add your server