Пример #1
0
 /**
  * Authenticate the received token and returns an authenticated token.
  *
  * @param TokenInterface        $token        The token generated with the login key.
  * @param UserProviderInterface $userProvider A user provider.
  * @param string                $providerKey  The security providerKey (The firewall security area)
  *
  * @return PreAuthenticatedToken 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());
 }
Пример #2
0
 /**
  * Get authenticated user
  *
  * @param string $role Role
  *
  * @return mixed User for authentication
  */
 public function getAuthenticationUser($role)
 {
     return 'ROLE_ADMIN' === $role ? $this->adminUserRepository->findOneBy(['email' => '*****@*****.**']) : $this->customerRepository->find(['email' => '*****@*****.**']);
 }