8000 [Worflow] Fixed GuardListener when using the new Security system · symfony/symfony@d4c3c69 · GitHub
[go: up one dir, main page]

Skip to content

Commit d4c3c69

Browse files
committed
[Worflow] Fixed GuardListener when using the new Security system
1 parent b128423 commit d4c3c69

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,8 @@ private function getVariables(GuardEvent $event): array
7676
{
7777
$token = $this->tokenStorage->getToken();
7878

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

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

0 commit comments

Comments
 (0)
0