F
Filamentβ€’16mo ago
RobinDev

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 Kochβ€’16mo ago
I think via mount method? It's a standard LW component
RobinDev
RobinDevβ€’16mo ago
how would you do that I want it to also be removed from the navigation
pechtelt
pechteltβ€’16mo ago
@RobinDev For navigation you can use shouldRegisterNavigation() and return an bool. or create a policy
Dennis Koch
Dennis Kochβ€’16mo ago
Policies are not meant for pages
AlexAnder
AlexAnderβ€’16mo 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
pechteltβ€’16mo 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 Kochβ€’16mo ago
But your edit page is part of a resource? It works with resources but not with custom pages
pechtelt
pechteltβ€’16mo ago
Right! Ah, question misunderstood! Thanks!
Paul Mercado
Paul Mercadoβ€’3mo 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
ianclemenceβ€’4w ago
Hi, did you get a solution for this? I'm facing a similar challenge