bezhanSalleh / filament-shield

The easiest and most intuitive way to add access management to your Filament Admin Resources, Pages & Widgets through `spatie/laravel-permission`
MIT License
1.49k stars 174 forks source link

Laravel 11 Roles visible/editable always to anyone #407

Closed core45 closed 1 month ago

core45 commented 1 month ago

In Laravel 11 the Roles are visible and editable to anyone regardless of his rights.

What is weird the rights work perfectly well with any other model

This is my User model:

class User extends Authenticatable implements FilamentUser, MustVerifyEmail
{
    use HasFactory, Notifiable;
    use HasRoles;
    use HasPanelShield;

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

    public function getFilamentRoles()
    {
        return $this->roles->pluck('name');
    }
}

What do I do wrong? The Rights settings should be available only to the super_admin obviously.

chadriae commented 1 month ago

In the filament-shield.php config file edit this line to: register_role_policy' => [ 'enabled' => true, ]

core45 commented 1 month ago

Thank you. This should be enabled by default...