Skip to content

Commit

Permalink
Deprecated ROLE_PREVIOUS_ADMIN
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Feb 25, 2020
1 parent ff9b8da commit 7a77762
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public function vote(TokenInterface $token, $subject, array $attributes)

$result = VoterInterface::ACCESS_DENIED;
foreach ($roles as $role) {
if ('ROLE_PREVIOUS_ADMIN' === $role) {
trigger_deprecation('symfony/security-core', '5.1', 'The ROLE_PREVIOUS_ADMIN role is deprecated and will be removed in version 6.0, use the IS_IMPERSONATOR attribute instead.');
}

if ($attribute === $role) {
return VoterInterface::ACCESS_GRANTED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ public function getVoteTests()
];
}

/**
* @group legacy
* @expectedDeprecation Since symfony/security-core 5.1: The ROLE_PREVIOUS_ADMIN role is deprecated and will be removed in version 6.0, use the IS_IMPERSONATOR attribute instead.
*/
public function testDeprecatedRolePreviousAdmin()
{
$voter = new RoleVoter();

$voter->vote($this->getTokenWithRoleNames(['ROLE_USER', 'ROLE_PREVIOUS_ADMIN']), null, ['ROLE_PREVIOUS_ADMIN']);
}

protected function getTokenWithRoleNames(array $roles)
{
$token = $this->getMockBuilder(AbstractToken::class)->getMock();
Expand Down

0 comments on commit 7a77762

Please sign in to comment.