Skip to content

Commit f364ce6

Browse files
[Security] make TokenInterface::getUser() nullable to tell about unauthenticated tokens
1 parent 4be64f9 commit f364ce6

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

EventListener/UserCheckerListener.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public function preCheckCredentials(CheckPassportEvent $event): void
4646
public function postCheckCredentials(AuthenticationSuccessEvent $event): void
4747
{
4848
$user = $event->getAuthenticationToken()->getUser();
49-
// @deprecated since 5.4, $user will always be an UserInterface instance
5049
if (!$user instanceof UserInterface) {
5150
return;
5251
}

Firewall/AccessListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function authenticate(RequestEvent $event)
114114

115115
// @deprecated since Symfony 5.4
116116
if (method_exists($token, 'isAuthenticated') && !$token->isAuthenticated(false)) {
117-
trigger_deprecation('symfony/core', '5.4', 'Returning false from "%s()" is deprecated and won\'t have any effect in Symfony 6.0 as security tokens will always be considered authenticated.');
117+
trigger_deprecation('symfony/core', '5.4', 'Returning false from "%s()" is deprecated, return null from "getUser()" instead.');
118118

119119
if ($this->authManager) {
120120
$token = $this->authManager->authenticate($token);

0 commit comments

Comments
 (0)