Esempio n. 1
0
 /**
  * {@InheritDoc}
  */
 protected function attemptAuthentication(Request $request)
 {
     $username = $request->get('_username', null, true);
     $request->getSession()->set(Security::LAST_USERNAME, $username);
     $token = new ChoiceAuthToken();
     $token->setUsername($username);
     $token->setProviderKey($this->providerKey);
     return $this->authenticationManager->authenticate($token);
 }
Esempio n. 2
0
 public function authenticate(TokenInterface $token)
 {
     $user = $this->userProvider->loadUserByUsername($token->getUsername());
     if (!$user) {
         throw new AuthenticationException('The authentication failed.');
     }
     $authenticatedToken = new ChoiceAuthToken($user->getRoles());
     $authenticatedToken->setAttributes($token->getAttributes());
     $authenticatedToken->setUser($user);
     $authenticatedToken->setProviderKey($this->providerKey);
     $authenticatedToken->setAuthenticated(true);
     return $authenticatedToken;
 }