Deprecated ROLE_PREVIOUS_ADMIN
This commit is contained in:
parent
ff9b8dae88
commit
dce55f352a
|
@ -40,6 +40,10 @@ class RoleVoter implements VoterInterface
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('ROLE_PREVIOUS_ADMIN' === $attribute) {
|
||||||
|
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.');
|
||||||
|
}
|
||||||
|
|
||||||
$result = VoterInterface::ACCESS_DENIED;
|
$result = VoterInterface::ACCESS_DENIED;
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
if ($attribute === $role) {
|
if ($attribute === $role) {
|
||||||
|
|
|
@ -44,6 +44,17 @@ class RoleVoterTest extends TestCase
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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)
|
protected function getTokenWithRoleNames(array $roles)
|
||||||
{
|
{
|
||||||
$token = $this->getMockBuilder(AbstractToken::class)->getMock();
|
$token = $this->getMockBuilder(AbstractToken::class)->getMock();
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2.5",
|
"php": "^7.2.5",
|
||||||
"symfony/event-dispatcher-contracts": "^1.1|^2",
|
"symfony/event-dispatcher-contracts": "^1.1|^2",
|
||||||
"symfony/service-contracts": "^1.1.6|^2"
|
"symfony/service-contracts": "^1.1.6|^2",
|
||||||
|
"symfony/deprecation-contracts": "^2.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"psr/container": "^1.0",
|
"psr/container": "^1.0",
|
||||||
|
|
Reference in New Issue