|
24 | 24 | use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
|
25 | 25 | use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
26 | 26 | use Symfony\Component\Security\Core\User\UserInterface;
|
| 27 | +use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator; |
27 | 28 | use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
|
28 | 29 | use Symfony\Component\Security\Http\Authenticator\InteractiveAuthenticatorInterface;
|
29 | 30 | use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface;
|
@@ -77,7 +78,7 @@ public function authenticateUser(UserInterface $user, AuthenticatorInterface $au
|
77 | 78 | // create an authentication token for the User
|
78 | 79 | // @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
|
79 | 80 | $passport = new SelfValidatingPassport(new UserBadge(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), function () use ($user) { return $user; }), $badges);
|
80 |
| - $token = method_exists($authenticator, 'createToken') ? $authenticator->createToken($passport, $this->firewallName) : $authenticator->createAuthenticatedToken($passport, $this->firewallName); |
| 81 | + $token = method_exists($authenticator, 'createToken') || ($authenticator instanceof AbstractAuthenticator && AbstractAuthenticator::class === (new \ReflectionMethod($authenticator, 'createAuthenticatedToken'))->getDeclaringClass()->getName()) ? $authenticator->createToken($passport, $this->firewallName) : $authenticator->createAuthenticatedToken($passport, $this->firewallName); |
81 | 82 |
|
82 | 83 | // announce the authentication token
|
83 | 84 | $token = $this->eventDispatcher->dispatch(new AuthenticationTokenCreatedEvent($token, $passport))->getAuthenticatedToken();
|
@@ -191,7 +192,7 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req
|
191 | 192 | }
|
192 | 193 |
|
193 | 194 | // create the authentication token
|
194 |
| - $authenticatedToken = method_exists($authenticator, 'createToken') ? $authenticator->createToken($passport, $this->firewallName) : $authenticator->createAuthenticatedToken($passport, $this->firewallName); |
| 195 | + $authenticatedToken = method_exists($authenticator, 'createToken') || ($authenticator instanceof AbstractAuthenticator && AbstractAuthenticator::class === (new \ReflectionMethod($authenticator, 'createAuthenticatedToken'))->getDeclaringClass()->getName()) ? $authenticator->createToken($passport, $this->firewallName) : $authenticator->createAuthenticatedToken($passport, $this->firewallName); |
195 | 196 |
|
196 | 197 | // announce the authentication token
|
197 | 198 | $authenticatedToken = $this->eventDispatcher->dispatch(new AuthenticationTokenCreatedEvent($authenticatedToken, $passport))->getAuthenticatedToken();
|
|
0 commit comments