Skip to content

Commit

Permalink
Merge pull request #238 from fcharlaix-opendsi/group_gid
Browse files Browse the repository at this point in the history
Use group ID and not display name on remove
  • Loading branch information
pulsejet authored Aug 30, 2023
2 parents b3ca9f9 + 20192ac commit 7b708d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Service/LoginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,15 @@ private function updateUserGroups(IUser $user, array $groupNames, array $profile
// Remove user from groups not present
$currentUserGroups = $this->groupManager->getUserGroups($user);
foreach ($currentUserGroups as $currentUserGroup) {
if (($key = array_search($currentUserGroup->getDisplayName(), $groupNames, true)) !== false) {
if (($key = array_search($currentUserGroup->getGID(), $groupNames, true)) !== false) {
// User is already in group - don't process further
unset($groupNames[$key]);
} else {
// User is not supposed to be in this group
// Remove the user ONLY if we're using profile groups
// or the group is the `admin` group and we manage admin role
if ($this->attr->hasGroups($profile)
|| ($this->attr->managesAdmin() && 'admin' === $currentUserGroup->getDisplayName())) {
|| ($this->attr->managesAdmin() && 'admin' === $currentUserGroup->getGID())) {
$currentUserGroup->removeUser($user);
}
}
Expand Down

0 comments on commit 7b708d4

Please sign in to comment.