mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 18:13:48 +00:00
sending correct error if user does not exists
This commit is contained in:
@@ -45,17 +45,17 @@ class UserProvider implements UserProviderInterface
|
||||
|
||||
public function loadUserByUsername($username): UserInterface
|
||||
{
|
||||
$user = $this->em->createQuery(sprintf(
|
||||
"SELECT u FROM %s u "
|
||||
. "WHERE u.usernameCanonical = UNACCENT(LOWER(:pattern)) "
|
||||
. "OR "
|
||||
. "u.emailCanonical = UNACCENT(LOWER(:pattern))",
|
||||
User::class))
|
||||
->setParameter('pattern', $username)
|
||||
->getSingleResult();
|
||||
|
||||
if (NULL === $user) {
|
||||
throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
|
||||
try {
|
||||
$user = $this->em->createQuery(sprintf(
|
||||
"SELECT u FROM %s u "
|
||||
. "WHERE u.usernameCanonical = UNACCENT(LOWER(:pattern)) "
|
||||
. "OR "
|
||||
. "u.emailCanonical = UNACCENT(LOWER(:pattern))",
|
||||
User::class))
|
||||
->setParameter('pattern', $username)
|
||||
->getSingleResult();
|
||||
} catch (\Doctrine\ORM\NoResultException $e) {
|
||||
throw new UsernameNotFoundException(sprintf('Bad credentials.', $username));
|
||||
}
|
||||
|
||||
return $user;
|
||||
|
Reference in New Issue
Block a user