mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
fix error when creating user with username / email validation
This commit is contained in:
parent
4f9626e65f
commit
0a0a7e7c24
@ -48,6 +48,7 @@ class UserUniqueEmailAndUsername extends ConstraintValidator
|
||||
. "only on class ".User::class);
|
||||
}
|
||||
|
||||
if ($value->getId() !== null) {
|
||||
$countUsersByUsername = $this->em->createQuery(
|
||||
sprintf(
|
||||
"SELECT COUNT(u) FROM %s u "
|
||||
@ -58,6 +59,16 @@ class UserUniqueEmailAndUsername extends ConstraintValidator
|
||||
->setParameter('username', $value->getUsername())
|
||||
->setParameter('user', $value)
|
||||
->getSingleScalarResult();
|
||||
} else {
|
||||
$countUsersByUsername = $this->em->createQuery(
|
||||
sprintf(
|
||||
"SELECT COUNT(u) FROM %s u "
|
||||
. "WHERE u.usernameCanonical = LOWER(UNACCENT(:username)) ",
|
||||
User::class)
|
||||
)
|
||||
->setParameter('username', $value->getUsername())
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
if ($countUsersByUsername > 0) {
|
||||
$this->context
|
||||
@ -70,6 +81,7 @@ class UserUniqueEmailAndUsername extends ConstraintValidator
|
||||
;
|
||||
}
|
||||
|
||||
if ($value->getId() !== null) {
|
||||
$countUsersByEmail = $this->em->createQuery(
|
||||
sprintf(
|
||||
"SELECT COUNT(u) FROM %s u "
|
||||
@ -80,6 +92,16 @@ class UserUniqueEmailAndUsername extends ConstraintValidator
|
||||
->setParameter('email', $value->getEmail())
|
||||
->setParameter('user', $value)
|
||||
->getSingleScalarResult();
|
||||
} else {
|
||||
$countUsersByEmail = $this->em->createQuery(
|
||||
sprintf(
|
||||
"SELECT COUNT(u) FROM %s u "
|
||||
. "WHERE u.emailCanonical = LOWER(UNACCENT(:email))",
|
||||
User::class)
|
||||
)
|
||||
->setParameter('email', $value->getEmail())
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
if ($countUsersByEmail > 0) {
|
||||
$this->context
|
||||
|
Loading…
x
Reference in New Issue
Block a user