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
|
public function loadUserByUsername($username): UserInterface
|
||||||
{
|
{
|
||||||
$user = $this->em->createQuery(sprintf(
|
try {
|
||||||
"SELECT u FROM %s u "
|
$user = $this->em->createQuery(sprintf(
|
||||||
. "WHERE u.usernameCanonical = UNACCENT(LOWER(:pattern)) "
|
"SELECT u FROM %s u "
|
||||||
. "OR "
|
. "WHERE u.usernameCanonical = UNACCENT(LOWER(:pattern)) "
|
||||||
. "u.emailCanonical = UNACCENT(LOWER(:pattern))",
|
. "OR "
|
||||||
User::class))
|
. "u.emailCanonical = UNACCENT(LOWER(:pattern))",
|
||||||
->setParameter('pattern', $username)
|
User::class))
|
||||||
->getSingleResult();
|
->setParameter('pattern', $username)
|
||||||
|
->getSingleResult();
|
||||||
if (NULL === $user) {
|
} catch (\Doctrine\ORM\NoResultException $e) {
|
||||||
throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
|
throw new UsernameNotFoundException(sprintf('Bad credentials.', $username));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user