Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4e357b

Browse files
committed
Revert "bug #35944 [Security/Core] Fix wrong roles comparison (thlbaut)"
This reverts commit 2e46c63, reversing changes made to 47180fe.
1 parent 9084f89 commit d4e357b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,13 @@ private function hasUserChanged(UserInterface $user): bool
317317
return true;
318318
}
319319

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

323-
if (\count($userRoles) !== \count($currentUserRoles) || \count($userRoles) !== \count(array_intersect($userRoles, $currentUserRoles))) {
322+
if ($this instanceof SwitchUserToken) {
323+
$userRoles[] = 'ROLE_PREVIOUS_ADMIN';
324+
}
325+
326+
if (\count($userRoles) !== \count($this->getRoleNames()) || \count($userRoles) !== \count(array_intersect($userRoles, $this->getRoleNames()))) {
324327
return true;
325328
}
326329

src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public function getUserChangesAdvancedUser()
238238
*/
239239
public function testSetUserDoesNotSetAuthenticatedToFalseWhenUserDoesNotChange($user)
240240
{
241-
$token = new ConcreteToken(['ROLE_FOO']);
241+
$token = new ConcreteToken();
242242
$token->setAuthenticated(true);
243243
$this->assertTrue($token->isAuthenticated());
244244

0 commit comments

Comments
 (0)