Пример #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;
     }
 }
 /**
  * @param array $record
  *
  * @return array
  */
 public function processRecord(array $record)
 {
     if (is_null($this->user)) {
         /* @var TokenStorageInterface $securityTokenStorage */
         $securityTokenStorage = $this->container->get('security.token_storage');
         if ($securityTokenStorage !== null && $securityTokenStorage->getToken() !== null && $securityTokenStorage->getToken()->getUser() instanceof \Symfony\Component\Security\Core\User\AdvancedUserInterface) {
             $this->user = $securityTokenStorage->getToken()->getUser();
             $this->record['extra']['user']['username'] = $this->user->getUsername();
             $this->record['extra']['user']['roles'] = $this->user->getRoles();
             $this->record['extra']['user']['is_account_non_expired'] = $this->user->isAccountNonExpired();
             $this->record['extra']['user']['is_account_non_locked'] = $this->user->isAccountNonLocked();
             $this->record['extra']['user']['is_credentials_non_expired'] = $this->user->isCredentialsNonExpired();
             $this->record['extra']['user']['is_enabled'] = $this->user->isEnabled();
         }
     }
     return array_merge($record, $this->record);
 }
Пример #3
0
 /**
  * @param array $record
  *
  * @return array
  */
 public function processRecord(array $record)
 {
     if (is_null($this->user)) {
         /* @var SecurityContextInterface $securityContext */
         $securityContext = null;
         try {
             $this->container->get("security.context");
         } catch (ServiceCircularReferenceException $e) {
             //since the securitycontext is deprecated getting the context from the container results in a log line which tries to use this method again....
         }
         if ($securityContext !== null && $securityContext->getToken() !== null && $securityContext->getToken()->getUser() instanceof \Symfony\Component\Security\Core\User\AdvancedUserInterface) {
             $this->user = $securityContext->getToken()->getUser();
             $this->record['extra']['user']['username'] = $this->user->getUsername();
             $this->record['extra']['user']['roles'] = $this->user->getRoles();
             $this->record['extra']['user']['is_account_non_expired'] = $this->user->isAccountNonExpired();
             $this->record['extra']['user']['is_account_non_locked'] = $this->user->isAccountNonLocked();
             $this->record['extra']['user']['is_credentials_non_expired'] = $this->user->isCredentialsNonExpired();
             $this->record['extra']['user']['is_enabled'] = $this->user->isEnabled();
         }
     }
     return array_merge($record, $this->record);
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function checkPostAuth(UserInterface $user)
 {
     if (!$user instanceof AdvancedUserInterface) {
         return;
     }
     if (!$user->isAccountNonLocked()) {
         throw new LockedException('User account is locked.', $user);
     }
     if (!$user->isEnabled()) {
         throw new DisabledException('User account is disabled.', $user);
     }
     if (!$user->isAccountNonExpired()) {
         throw new AccountExpiredException('User account has expired.', $user);
     }
 }
Пример #5
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;
     }
 }
Пример #6
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;
     }
 }
Пример #7
0
 /**
  * Implementation of SecurityUserInterface.
  *
  * @param \Symfony\Component\Security\Core\User\UserInterface $user
  * @return Boolean
  */
 public function equals(SecurityUserInterface $user)
 {
     if (!$user instanceof User) {
         return false;
     }
     if ($this->getPassword() !== $user->getPassword()) {
         return false;
     }
     if ($this->getSalt() !== $user->getSalt()) {
         return false;
     }
     if ($this->getUsernameCanonical() !== $user->getUsernameCanonical()) {
         return false;
     }
     if ($this->isAccountNonExpired() !== $user->isAccountNonExpired()) {
         return false;
     }
     if ($this->isAccountNonLocked() !== $user->isAccountNonLocked()) {
         return false;
     }
     if ($this->isCredentialsNonExpired() !== $user->isCredentialsNonExpired()) {
         return false;
     }
     if ($this->isEnabled() !== $user->isEnabled()) {
         return false;
     }
     return true;
 }
Пример #8
0
 public function isAccountNonLocked()
 {
     return $this->wrappedUser instanceof AdvancedUserInterface ? $this->wrappedUser->isAccountNonLocked() : true;
 }
Пример #9
0
 public function equals(UserInterface $user)
 {
     if (!$user instanceof User) {
         return false;
     }
     if ($this->password !== $user->getPassword()) {
         return false;
     }
     if ($this->getSalt() !== $user->getSalt()) {
         return false;
     }
     if ($this->isAccountNonExpired() !== $user->isAccountNonExpired()) {
         return false;
     }
     if (!$this->locked !== $user->isAccountNonLocked()) {
         return false;
     }
     if ($this->isCredentialsNonExpired() !== $user->isCredentialsNonExpired()) {
         return false;
     }
     if ($this->enabled !== $user->isEnabled()) {
         return false;
     }
     return true;
 }