Ejemplo n.º 1
0
 public function checkPostAuth(UserInterface $user)
 {
     if (!$user instanceof AdvancedUserInterface) {
         return;
     }
     if (!$user->isAccountNonLocked()) {
         $ex = new LockedException('User account is locked.');
         $ex->setUser($user);
         throw $ex;
     }
     if (!$user->isEnabled() and $user->getStatus() == User::STATUS_BAD_EMAIL) {
         $ex = new DisabledException('BAD_EMAIL');
         $ex->setUser($user);
         throw $ex;
     }
     if (!$user->isEnabled()) {
         $ex = new DisabledException('DISABLED');
         if ($user instanceof User && $user->getConfirmationToken()) {
             $ex = new DisabledException('DISABLED:' . Strings::base64EncodeUrl($user->getEmail()));
         }
         $ex->setUser($user);
         throw $ex;
     }
     if (!$user->isAccountNonExpired()) {
         $ex = new AccountExpiredException('User account has expired.');
         $ex->setUser($user);
         throw $ex;
     }
 }
Ejemplo n.º 2
0
 /**
  * Based on the LDAP error code and the LDAP type, throw any specific exceptions detected.
  *
  * @param UserInterface $user The user object.
  * @param int $code The extended LDAP error code.
  * @param string $ldapType The LDAP type used for authentication.
  */
 public function checkLdapErrorCode(UserInterface $user, $code, $ldapType)
 {
     if ($ldapType == LdapConnection::TYPE_AD && $code == ADResponseCodes::ACCOUNT_LOCKED) {
         $ex = new LockedException('User account is locked.');
         $ex->setUser($user);
         throw $ex;
     }
     if ($ldapType == LdapConnection::TYPE_AD && $code == ADResponseCodes::ACCOUNT_PASSWORD_MUST_CHANGE) {
         $ex = new CredentialsExpiredException('User credentials have expired.');
         $ex->setUser($user);
         throw $ex;
     }
     if ($ldapType == LdapConnection::TYPE_AD && $code == ADResponseCodes::ACCOUNT_DISABLED) {
         $ex = new DisabledException('User account is disabled.');
         $ex->setUser($user);
         throw $ex;
     }
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function checkPreAuth(UserInterface $user)
 {
     if (!$user instanceof AdvancedUserInterface) {
         return;
     }
     if (!$user->isAccountNonLocked()) {
         $ex = new LockedException('Le compte est actuellement bloqué. Veuillez patienter qu\'un administrateur le déverrouille.');
         $ex->setUser($user);
         throw $ex;
     }
     if (!$user->isEnabled()) {
         $ex = new DisabledException('User account is disabled.');
         $ex->setUser($user);
         throw $ex;
     }
     if (!$user->isAccountNonExpired()) {
         $ex = new AccountExpiredException('User account has expired.');
         $ex->setUser($user);
         throw $ex;
     }
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function checkPreAuth(UserInterface $user)
 {
     if (!$user instanceof AdvancedUserInterface) {
         return;
     }
     if (!$user->isAccountNonLocked()) {
         $ex = new LockedException('User account is locked.');
         $ex->setUser($user);
         throw $ex;
     }
     if (!$user->isEnabled()) {
         $ex = new DisabledException('User account is disabled.');
         $ex->setUser($user);
         throw $ex;
     }
     if (!$user->isAccountNonExpired()) {
         $ex = new AccountExpiredException('User account has expired.');
         $ex->setUser($user);
         throw $ex;
     }
 }