F
Filament3mo ago
Sivan

Unable to login when create new role

Hi everyone, I am using bezhanSalleh/filament-shield package to created a new role. I created new role called "view_data," which only allows viewing data. Then, I created a new user and assigned this "view_data" role to him. However, when he tries to log in, it shows a "403 Forbidden" error. How can I fix this issue? Can anyone help me with this?
Solution:
The HasPanelShield trait provides an implementation for the canAccessPanel method, determining access based on whether the user possesses the super_admin role or the panel_user role. It also assigns the panel_user role to the user upon creation and removes it upon deletion. Ofcourse the role names can be changed from the plugin's configuration file.
It's not an issue but the intended use case if you read the docs....
Jump to solution
8 Replies
Dennis Koch
Dennis Koch3mo ago
Forbidden right on the login or after login?
Sivan
Sivan3mo ago
after login
Dennis Koch
Dennis Koch3mo ago
What permissions did you set?
Sivan
Sivan3mo ago
These are the screenshot for your reference @Dennis Koch
No description
No description
No description
Dennis Koch
Dennis Koch3mo ago
Is this maybe an issue because you limited canAccessPanel() on the User model?
Sivan
Sivan3mo ago
By default, they provide roles like "super admin" and "panel user," which work fine. However, when I create a new custom role and assign it to a user, it doesn't seem to work properly. Any ideas on how to resolve this issue? The issue seems to be related to using the HasPanelShield trait in user model. This is likely causing the problem. @Dennis Koch , I think the super admin and panel user have the permission to access the panel. how can i access panel other than roles @Dennis Koch I fix this issues, i remove the HasPanelShield from the user model now it works fine
Solution
Dennis Koch
Dennis Koch3mo ago
The HasPanelShield trait provides an implementation for the canAccessPanel method, determining access based on whether the user possesses the super_admin role or the panel_user role. It also assigns the panel_user role to the user upon creation and removes it upon deletion. Ofcourse the role names can be changed from the plugin's configuration file.
It's not an issue but the intended use case if you read the docs.
Sivan
Sivan3mo ago
Sure @Dennis Koch
Want results from more Discord servers?
Add your server