Need advice on the login logic of my application
Hi, I need some advice on the connection logic of the application I am currently working on and on the implementation I have already set up.
To put it simply, to access the application, one must be logged in. At the user level, there are 2 access levels:
- Administrators: who can access the application and the Filament dashboard;
- Clients who can access the application, but not the Filament dashboard.
I would like to use the Filament login form, which perfectly matches my expectations.
So, for that, I modified the Filament Login class and the toResponse() method to handle redirection based on whether the user is an administrator or a client.
The idea is to manage the redirection based on the base URL and the user role.
I also created a
home
route with a custom Middleware (RedirectIfNotAuthenticated) :
Everything seems to be working correctly; the only "hiccup" is that the login URL remains tied to admin/login
and I have the feeling we can't change it (or perhaps I just haven't found how...).
Does that seem correct to you? Or is there a more optimal approach?
Thank you in advance for your advice π3 Replies
You can just clone the login class completely, remove the filamentphp ->login() and have it as a standalone livewire login class. After logging in you decide where to go.
All login() does is redirect you to the login class and registers the route to access it
Thank you for your response.
I thought about it at first, but I wasn't quite sure how to retrieve the entire nested layout of filament (not just the login form but HTML, body, ...), which I feel are other Livewire components
Knowing that I will also need to do the same with the passwordReset. The whole thing seemed a bit tricky to me, but I might be mistaken... π
And the advantage here is that I can put it on Filament without having to tweak my views...
Aside from the URL, do you see any potential issues with what Iβve implemented?
Just add the route to your main routes config:
Then go to login...
Fairly sure that's all you need