Merge pull request #15911 from Fiala06/patch-1

Fixed duplicate entries preventing LDAP sync from continuing
This commit is contained in:
snipe 2025-03-04 12:49:54 +00:00 committed by GitHub
commit 6f847294ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -434,8 +434,12 @@ class LdapSync extends Command
$item['note'] = $item['createorupdate'];
$item['status'] = 'success';
if ($item['createorupdate'] === 'created' && $ldap_default_group) {
$user->groups()->attach($ldap_default_group);
// Check if the relationship already exists
if (!$user->groups()->where('group_id', $ldap_default_group)->exists()) {
$user->groups()->attach($ldap_default_group);
}
}
//updates assets location based on user's location
if ($user->wasChanged('location_id')) {
foreach ($user->assets as $asset) {