Skip to content

Commit

Permalink
Fix wrong roles comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
thlbaut committed Mar 3, 2020
1 parent d246e94 commit 3d9ef9b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,15 @@ private function hasUserChanged(UserInterface $user): bool
if ($this->user->getSalt() !== $user->getSalt()) {
return true;
}


$currentUserRoles = array_map('strval', (array) $this->user->getRoles());
$userRoles = array_map('strval', (array) $user->getRoles());

if ($this instanceof SwitchUserToken) {
$userRoles[] = 'ROLE_PREVIOUS_ADMIN';
}

if (\count($userRoles) !== \count($this->getRoleNames()) || \count($userRoles) !== \count(array_intersect($userRoles, $this->getRoleNames()))) {
if (\count($userRoles) !== \count($currentUserRoles) || \count($userRoles) !== \count(array_intersect($userRoles, $currentUserRoles))) {
return true;
}

Expand Down

0 comments on commit 3d9ef9b

Please sign in to comment.