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,16 +48,27 @@ class UserUniqueEmailAndUsername extends ConstraintValidator
|
|||||||
. "only on class ".User::class);
|
. "only on class ".User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
$countUsersByUsername = $this->em->createQuery(
|
if ($value->getId() !== null) {
|
||||||
sprintf(
|
$countUsersByUsername = $this->em->createQuery(
|
||||||
"SELECT COUNT(u) FROM %s u "
|
sprintf(
|
||||||
. "WHERE u.usernameCanonical = LOWER(UNACCENT(:username)) "
|
"SELECT COUNT(u) FROM %s u "
|
||||||
. "AND u != :user",
|
. "WHERE u.usernameCanonical = LOWER(UNACCENT(:username)) "
|
||||||
User::class)
|
. "AND u != :user",
|
||||||
)
|
User::class)
|
||||||
->setParameter('username', $value->getUsername())
|
)
|
||||||
->setParameter('user', $value)
|
->setParameter('username', $value->getUsername())
|
||||||
->getSingleScalarResult();
|
->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) {
|
if ($countUsersByUsername > 0) {
|
||||||
$this->context
|
$this->context
|
||||||
@ -70,16 +81,27 @@ class UserUniqueEmailAndUsername extends ConstraintValidator
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
$countUsersByEmail = $this->em->createQuery(
|
if ($value->getId() !== null) {
|
||||||
sprintf(
|
$countUsersByEmail = $this->em->createQuery(
|
||||||
"SELECT COUNT(u) FROM %s u "
|
sprintf(
|
||||||
. "WHERE u.emailCanonical = LOWER(UNACCENT(:email)) "
|
"SELECT COUNT(u) FROM %s u "
|
||||||
. "AND u != :user",
|
. "WHERE u.emailCanonical = LOWER(UNACCENT(:email)) "
|
||||||
User::class)
|
. "AND u != :user",
|
||||||
)
|
User::class)
|
||||||
->setParameter('email', $value->getEmail())
|
)
|
||||||
->setParameter('user', $value)
|
->setParameter('email', $value->getEmail())
|
||||||
->getSingleScalarResult();
|
->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) {
|
if ($countUsersByEmail > 0) {
|
||||||
$this->context
|
$this->context
|
||||||
|
Loading…
x
Reference in New Issue
Block a user