8000 bug #39671 [Worflow] Fixed GuardListener when using the new Security … · symfony/symfony@b15bfc4 · GitHub
[go: up one dir, main page]

Skip to content

Commit b15bfc4

Browse files
committed
bug #39671 [Worflow] Fixed GuardListener when using the new Security system (lyrixx)
This PR was merged into the 5.2 branch. Discussion ---------- [Worflow] Fixed GuardListener when using the new Security system | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #39505 | License | MIT | Doc PR | Commits ------- bd26a79 [Worflow] Fixed GuardListener when using the new Security system
2 parents 15e2067 + bd26a79 commit b15bfc4

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

src/Symfony/Component/Workflow/EventListener/GuardListener.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
1818
use Symfony\Component\Validator\Validator\ValidatorInterface;
1919
use Symfony\Component\Workflow\Event\GuardEvent;
20-
use Symfony\Component\Workflow\Exception\InvalidTokenConfigurationException;
2120
use Symfony\Component\Workflow\TransitionBlocker;
2221

2322
/**
@@ -76,15 +75,8 @@ private function getVariables(GuardEvent $event): array
7675
{
7776
$token = $this->tokenStorage->getToken();
7877

79-
if (null === $token) {
80-
throw new InvalidTokenConfigurationException(sprintf('There are no tokens available for workflow "%s".', $event->getWorkflowName()));
81-
}
82-
8378
$variables = [
84-
'token' => $token,
85-
'user' => $token->getUser(),
8679
'subject' => $event->getSubject(),
87-
'role_names' => $this->roleHierarchy->getReachableRoleNames($token->getRoleNames()),
8880
// needed for the is_granted expression function
8981
'auth_checker' => $this->authorizationChecker,
9082
// needed for the is_* expression function
@@ -93,6 +85,18 @@ private function getVariables(GuardEvent $event): array
9385
'validator' => $this->validator,
9486
];
9587

96-
return $variables;
88+
if (null === $token) {
89+
return $variables + [
90+
'token' => null,
91+
'user' => null,
92+
'role_names' => [],
93+
];
94+
}
95+
96+
return $variables + [
97+
'token' => $token,
98+
'user' => $token->getUser(),
99+
'role_names' => $this->roleHierarchy->getReachableRoleNames($token->getRoleNames()),
100+
];
97101
}
98102
}

src/Symfony/Component/Workflow/Exception/InvalidTokenConfigurationException.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0