public function loadUserByUsername($user)
{
try {
// SecurityContext always tries to authenticate anonymous users when checking granted access.
// In that case $user is an instance of \eZ\Publish\Core\MVC\Symfony\Security\User.
// We don't need to reload the user here.
if ($user instanceof UserInterface) {
return $user;
}
return new User($this->repository->getUserService()->loadUserByLogin($user), array('ROLE_USER'));
} catch (NotFoundException $e) {
throw new UsernameNotFoundException($e->getMessage(), 0, $e);
}
}