refactoring of RequestSecurityEventSubscriber
This commit is contained in:
parent
3017880a64
commit
e7b4f7f81e
|
@ -44,15 +44,15 @@ class RequestSecurityEventSubscriber implements EventSubscriberInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$operator = $node->getSecurityOperator();
|
$operator = $node->getSecurityOperator();
|
||||||
$exception = new AccessDeniedException('Access denied');
|
$exception = new AccessDeniedException('Access denied.');
|
||||||
$isAuthorized = false;
|
|
||||||
|
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
$isGranted = $this->authorizationChecker->isGranted($role);
|
$isGranted = $this->authorizationChecker->isGranted($role);
|
||||||
|
|
||||||
if ('or' === $operator && $isGranted) {
|
if ('or' === $operator && $isGranted) {
|
||||||
return;
|
return;
|
||||||
} elseif ('and' === $operator && !$isGranted) {
|
}
|
||||||
|
if ('and' === $operator && !$isGranted) {
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue