custom page access

How can i set a gate/access for a custom page? I only want people with a specific role to be able to visit that page
11 Replies
Dennis Koch
Dennis Koch2y ago
I think via mount method? It's a standard LW component
RobinDev
RobinDevOP2y ago
how would you do that I want it to also be removed from the navigation
pechtelt
pechtelt2y ago
@RobinDev For navigation you can use shouldRegisterNavigation() and return an bool. or create a policy
Dennis Koch
Dennis Koch2y ago
Policies are not meant for pages
AlexAnder
AlexAnder2y ago
I use filament shield and then on custom page add "use HasPageShield;" and on role select specific role to access to custom page
pechtelt
pechtelt2y ago
Just starting... 🙂 But then i think i'm using it in the wrong way bc if in UserPolicy, for example, I return the function update() false then you don't have access to update the model but then you can't access the /edit page either. Or am I abusing this?
Dennis Koch
Dennis Koch2y ago
But your edit page is part of a resource? It works with resources but not with custom pages
pechtelt
pechtelt2y ago
Right! Ah, question misunderstood! Thanks!
Paul Mercado
Paul Mercado9mo ago
What if the custom page is inside the resource? hasPageShield is not working. I am using Filament-shield. I want to restrict users for accessing the custom page inside the ex. EmployeeResource folder
ianclemence
ianclemence8mo ago
Hi, did you get a solution for this? I'm facing a similar challenge

Did you find this page helpful?