8000 bug #41700 [Security] Fix deprecation notice on TokenInterface::getUs… · symfony/symfony@66f7b7a · GitHub
[go: up one dir, main page]

Skip to content

Commit 66f7b7a

Browse files
bug #41700 [Security] Fix deprecation notice on TokenInterface::getUser() stringable return (tscni)
This PR was merged into the 5.3 branch. Discussion ---------- [Security] Fix deprecation notice on TokenInterface::getUser() stringable return | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT `AuthenticatorManager` raises a deprecation notice about the missing implementation of `UserInterface::getUserIdentifier()` when `TokenInterface::getUser()` returns a string. This fixes that issue. Commits ------- 8a2bd4d [Security] Fix deprecation notice on TokenInterface::getUser() stringable return
2 parents 35bae6b + 8a2bd4d commit 66f7b7a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req
230230
private function handleAuthenticationSuccess(TokenInterface $authenticatedToken, PassportInterface $passport, Request $request, AuthenticatorInterface $authenticator): ?Response
231231
{
232232
// @deprecated since 5.3
233-
if (!method_exists($authenticatedToken->getUser(), 'getUserIdentifier')) {
233+
$user = $authenticatedToken->getUser();
234+
if ($user instanceof UserInterface && !method_exists($user, 'getUserIdentifier')) {
234235
trigger_deprecation('symfony/security-core', '5.3', 'Not implementing method "getUserIdentifier(): string" in user class "%s" is deprecated. This method will replace "getUsername()" in Symfony 6.0.', get_debug_type($authenticatedToken->getUser()));
235236
}
236237

0 commit comments

Comments
 (0)
0