Sulu\Component\Security\Authentication\UserRepositoryInterface::findUserByIdentifier PHP Method

findUserByIdentifier() public method

Finds a user for a given email or username.
public findUserByIdentifier ( string $identifier ) : Sulu\Component\Security\Authentication\UserInterface
$identifier string The email-address or username
return Sulu\Component\Security\Authentication\UserInterface
    public function findUserByIdentifier($identifier);

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function loadUserByUsername($username)
 {
     $exceptionMessage = sprintf('Unable to find an Sulu\\Component\\Security\\Authentication\\UserInterface object identified by %s', $username);
     try {
         $user = $this->userRepository->findUserByIdentifier($username);
         if (!$user->getEnabled()) {
             throw new DisabledException();
         }
         if ($user->getLocked()) {
             throw new LockedException();
         }
         foreach ($user->getRoleObjects() as $role) {
             if ($role->getSystem() === $this->getSystem()) {
                 return $user;
             }
         }
     } catch (NoResultException $e) {
         throw new UsernameNotFoundException($exceptionMessage, 0, $e);
     }
     throw new UsernameNotFoundException($exceptionMessage, 0);
 }