Merge pull request #15911 from Fiala06/patch-1
Fixed duplicate entries preventing LDAP sync from continuing
This commit is contained in:
commit
6f847294ed
1 changed files with 5 additions and 1 deletions
|
@ -434,8 +434,12 @@ class LdapSync extends Command
|
||||||
$item['note'] = $item['createorupdate'];
|
$item['note'] = $item['createorupdate'];
|
||||||
$item['status'] = 'success';
|
$item['status'] = 'success';
|
||||||
if ($item['createorupdate'] === 'created' && $ldap_default_group) {
|
if ($item['createorupdate'] === 'created' && $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);
|
$user->groups()->attach($ldap_default_group);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//updates assets location based on user's location
|
//updates assets location based on user's location
|
||||||
if ($user->wasChanged('location_id')) {
|
if ($user->wasChanged('location_id')) {
|
||||||
foreach ($user->assets as $asset) {
|
foreach ($user->assets as $asset) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue