Middleware not applying on all the routes
I have a middle ware that checks for role of the authenticated user and does some function.I want it to apply on all the routes in the app so i added it in the filament config file under 'base' array .However the middle ware works when i access the dashboard route only.
14 Replies
What version of Filament are you using? Have you added some multi-tenancy or changed the default routing at all?
I'm on v2 ...Haven't changed any of the default routing.
Can you share the
middleware
array from the config file? And the middleware you created? And this is the middleware
It looks like this only applies the
isVerified
check if the authenticated user is a manager. Could that be causing the issue?
Also, if you add verified
to your auth
array, Filament should automatically enforce verification for all users
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
the isVerified is a boolean property i added on the User model.
oh ok
alright so this route definition
return redirect()->route('manager.resources.biodata.index');
tells me that you're using multi-tenancy
standard Filament routes look like filament.resources.biodata.index
there should be a config/manager.php
where a separate group of middleware is defined
and that's the middleware applied to all manager
routesYeap true...I tried also to add the middleware to the base array of the manager.php but still the same result.
What route are you loading where you expect to call this middleware?
I want it to apply to all the routes.
I'm assuming you are using this package: https://github.com/artificertech/filament-multi-context
GitHub
GitHub - artificertech/filament-multi-context: A package for adding...
A package for adding multiple contexts to the filament admin panel - GitHub - artificertech/filament-multi-context: A package for adding multiple contexts to the filament admin panel
Is that right?
If that's the case, then you will need to apply it for each context. This package creates separate contexts and each context has it's own middleware
Yes. I tried to add the middleware in each of the contexts' config file .