Custom Middleware in Filament

I have a custom login in my Filament app but the problem is I'm having trouble in preventing users from going back to my custom login. I implemented a prevent-back-history middleware in my custom login but it's not working. I also added my custom middleware in ->middleware([ EncryptCookies::class, AddQueuedCookiesToResponse::class, StartSession::class, AuthenticateSession::class, ShareErrorsFromSession::class, VerifyCsrfToken::class, SubstituteBindings::class, DisableBladeIconComponents::class, DispatchServingFilamentEvent::class, PreventBackHistory::class, ]) ->authMiddleware([ Authenticate::class, ]); but whenever I pressed the back button, I always go back to my custom login. How to add a custom middleware in Filament to prevent users from going back to my custom login page?
Solution:
if you did it laravel way then your route is in web.php rigth? add guest middleware so only guest users would be able to access it than maybe
Jump to solution
4 Replies
krekas
krekas15mo ago
how did you done your custom login for accessing it? did you provide it in login()?
DysonSphere
DysonSphereOP15mo ago
No. I did it the Laravel way by making my own controller to handle the login request and return redirect()->route('filament.admin.pages.dashboard');
Solution
krekas
krekas15mo ago
if you did it laravel way then your route is in web.php rigth? add guest middleware so only guest users would be able to access it than maybe
DysonSphere
DysonSphereOP15mo ago
Okay. I'll try this! Thanks! I tried doing the guest middleware and it is a success, whenever I go back, it doesn't let me see my custom login anymore. However, I encountered another problem, my admin dashboard keeps on reloading nonstop. I already clear the cache and restart my server but I can't seem to find the problem. Update: I already solved it, I forgot to remove the custom middleware that I put in the web middleware in the Kernel.php
Want results from more Discord servers?
Add your server