mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
sending correct error if user does not exists
This commit is contained in:
parent
43edcfc416
commit
4be4ab3402
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user