refactoring of RequestSecurityEventSubscriber

This commit is contained in:
Simon Vieille 2022-03-10 22:31:17 +01:00
parent 3017880a64
commit e7b4f7f81e

View file

@ -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;
} }
} }