chiiya / filament-access-control

Admin user, role and permission management for Laravel Filament
MIT License
200 stars 25 forks source link

[ISSUE] Spatie\Permission\Exceptions\GuardDoesNotMatch with message 'The given role or permission should use guard `web` instead of `filament`.' #21

Closed vzool closed 2 years ago

vzool commented 2 years ago
>>> $user = User::find(11);
=> App\Models\User {#5313
     id: 11,
     email: "test@example.com",
     #password: "$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi",
     first_name: "مستخدم",
     last_name: "للإختبار",
     expires_at: null,
     two_factor_expires_at: null,
     two_factor_code: null,
     #remember_token: "NkUmKbJWD0j827WHpgFPBc5DkFCgdvNIh07mbxTaBlP9SB8pEYyzXrtAKPYL",
     created_at: "2022-10-04 02:15:20",
     updated_at: "2022-10-04 02:15:20",
   }

>>> $role = Spatie\Permission\Models\Role::first()
=> Spatie\Permission\Models\Role {#5300
     id: 1,
     name: "super-admin",
     guard_name: "filament",
     created_at: "2022-10-04 03:41:23",
     updated_at: "2022-10-04 03:41:23",
   }

>>> $user->assignRole($role);
Spatie\Permission\Exceptions\GuardDoesNotMatch with message 'The given role or permission should use guard `web` instead of `filament`.'
>>> 

How this can be resolved?

vzool commented 2 years ago
➜  git:(main) ✗ php artisan filament-access-control:install

 [OK] Filament Access Control has been installed successfully.                                                          
chiiya commented 2 years ago

Why are you trying to assign the Super Admin role to a User model? This package defines a custom admin user model: FilamentUser. Custom user models are not supported at this time.

chiiya commented 2 years ago

Closing due to inactivity.