示例#1
0
 /**
  * @param Credentials  Prihlasovaci udaje.
  * @throws AuthenticationException Chyba v overeni udaju.
  * @return Identitu uzivatele.
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     try {
         $user = $this->usersService->getUserEmail($username);
     } catch (Exceptions\NoResultException $ex) {
         $this->getLogger()->addAlert("### ATTEMPT TO LOG IN WITH INVALID EMAIL ### - exception = " . $ex);
         throw new AuthenticationException("securityModule.loginControl.messages.invalidCredentials", self::IDENTITY_NOT_FOUND);
     }
     if (!Passwords::verify($password, $user->password)) {
         $this->getLogger()->addAlert("### ATTEMPT TO LOG IN WITH INVALID PASSWORD ### - tried password = "******"securityModule.loginControl.messages.invalidCredentials", self::INVALID_CREDENTIAL);
     }
     if (!$user->active) {
         $this->getLogger()->addAlert("### ATTEMPT TO LOG TO INACTIVE ACCOUNT ### - account id = " . $user->getId());
         throw new AuthenticationException("securityModule.loginControl.messages.userUnactive");
     }
     $this->usersService->updateLastLogin($user);
     $identity = $user;
     return $identity;
 }