The LDAP connection [mysql] does not exist.
somzoli opened this issue · comments
Hi
If i use filament-shield with LdapRecord and i want to delete a Role it show an error:
The LDAP connection [mysql] does not exist.
If i set guard name in role to "db", the deletion is working.
auth config:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'db' => [
'driver' => 'session',
'provider' => 'db',
],
],
'providers' => [
'db' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'users' => [
'driver' => 'ldap',
'model' => LdapRecord\Models\ActiveDirectory\User::class,
'rules' => [],
'scopes' => [],
'database' => [
'model' => App\Models\User::class,
'sync_passwords' => true,
'sync_attributes' => [
'name' => 'sAMAccountName',
'email' => 'mail',
],
'sync_existing' => [
'name' => 'sAMAccountName',
'email' => 'mail',
],
],
],
],
Can you help with this?
My solution to avoid error:
Copy RoleResource from vendor and change delete actions:
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make()
->before(function ($record) {
$record->update(['guard_name' => 'db']);
}),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make()
->before(function ($records) {
$records->each->update(['guard_name' => 'db']);
}),
]);
Thanks,
Z
i really don't think it's a shield issue rather than how you setup the base package.
so if you wanna use multiple guards then i suggest you go through their documentation because there are a couple scenarios and gotchas you should be aware of.
https://spatie.be/docs/laravel-permission/v6/basic-usage/multiple-guards