public authenticateToken ( Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token, Symfony\Component\Security\Core\User\UserProviderInterface $userProvider, string $providerKey ) : |
||
$token | Symfony\Component\Security\Core\Authentication\Token\TokenInterface | The token generated with the login key. |
$userProvider | Symfony\Component\Security\Core\User\UserProviderInterface | A user provider. |
$providerKey | string | The security providerKey (The firewall security area) |
return | A pre-authenticated token generated using the user admin entity. |
public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
{
$loginKey = $token->getCredentials();
$user = $this->adminUserRepository->findOneBy(['oneTimeLoginHash' => $loginKey]);
if (!$user) {
throw new AuthenticationException(sprintf('Login Key "%s" does not exist.', $loginKey));
}
$user->setOneTimeLoginHash(null);
$this->adminUserObjectManager->flush();
return new PreAuthenticatedToken($user, $loginKey, $providerKey, $user->getRoles());
}