Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Karim_Taha's avatar

Filament Shield creating role

Hi everyone,

I am using bezhanSalleh/filament-shield package to created a new role. I created new role called "accountant" which only allows viewing some pages. Then, I created a new user and assigned this "accountant" role to him. However, when he tries to log in, it shows a "403 Forbidden" error. How can I fix this issue?

0 likes
4 replies
AddWebContribution's avatar

Actually this happens when the user has successfully logged in but doesn’t have permission to access the default Filament dashboard page (/admin or similar). Filament Shield is doing its job by denying access based on the assigned permissions to logged in user. Either you give them permission to access the dashboard or redirect them to something they are allowed to see after login.

1 like
lucvk's avatar

First step is to determine from where the 403 originates. Is it from the filament middelware or from the 'canAccess' method on the page?

General remark: I always use permissions to model access to filament resources/pages. Then group permissions in roles, and finally assign roles to users. This makes the code that actually checks the access unaware of roles and it integrates perfectly with standard laravel policiies.

1 like
Karim_Taha's avatar

@lucvk I solved it by adding canAccess function in User model:

public function canAccessPanel(\Filament\Panel $panel): bool { return true; }

Thank you.

Please or to participate in this conversation.