Change default route after login, and/or after being authenticated
I will try and explain this as best as I can. I basically want to add a landing page to my website. If the user isnt already logged in, after logging in, he shall be redirected to the landing page instead of /app panel. Otherwise, if he is logged in, and he goes at any page on the panel, so /app/*, he should be redirected to the landing page. I only want this to be shown once, thats why I added an appropriate column to the users table.
I tried doing this with middleware routes, however I had trouble finding out if the user is authinticated with
Auth::check()
.
To me this seems more like a laravel question, than filament. Thats why im marking it as non-filamant. Any help is appreciated.3 Replies
Sounds like you're doing some sort of "confirm that you've read the terms and conditions" or "welcome" splash page, that only displays the first time a person joins.
The last time I did that I created a new middleware that fired after the Authenticate middleware, and made sure to include that middleware in the controller/s that the user was most likely to hit
(in my case there were two possible dashboards, and even if somehow they went to a sub-page at some point, they'd be back to the dashboard at least once per "session", so they'd see the alert then even if it was a bit after they'd done something else .... I think that's slightly different than yours, but you could register the middleware on every controller (or Panel in Filament's case) )
The middleware would just check the flag field on the User record, and redirect to the page or just return the view.
If this is all related to a Filament Panel, then you'd register the middleware in the Panel.
Can you perhaps share what you did please?
Can't find that project right now.
But, here's one I hacked together using Laravel's
RedirectIfAuthenticated
... it's almost entirely that middleware, with just a couple lines changed:
then in my Panel, I added it to the existing list of middleware: