/**
* {@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);
}