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.6k stars 180 forks source link

super_admin role generation #371

Closed artjom closed 4 months ago

artjom commented 5 months ago

hey,

thanks for the great work! It seems, there's a logic error for the super_admin role creation. If the super_admin is disabled it still creates the super admin role, whenever a new policy is generated.

protected static function giveSuperAdminPermission(string | array | Collection $permissions): void { if (! Utils::isSuperAdminDefinedViaGate()) { $superAdmin = static::createRole(); $superAdmin->givePermissionTo($permissions); app(PermissionRegistrar::class)->forgetCachedPermissions(); } }

In my case, I don't need the super admin role at all, so I deactivated it in the config file. Still the role is added every time I'm generating a policy.