Skip to content

Commit

Permalink
Avoid duplicate validation message when trying to register a user wit…
Browse files Browse the repository at this point in the history
…h existing email
  • Loading branch information
josegar74 authored and fxprunayre committed Oct 17, 2024
1 parent e20820a commit 82fda12
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ user_password_changed='%s' password was updated.
user_password_notchanged=A problem occurred trying to change '%s' password. Contact the helpdesk.
user_password_invalid_changekey='%s' is an invalid change key for '%s'. Change keys are only valid for one day.
user_registered=User '%s' registered.
user_with_that_email_found=A user with this email or username already exists.
user_with_that_username_found=A user with this email or username already exists.
user_with_that_email_username_found=A user with this email or username already exists.
register_email_admin_subject=%s / New account for %s as %s
register_email_admin_message=Dear Admin,\n\
Newly registered user %s has requested %s access for %s.\n\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ user_password_sent=Si l''utilisateur existe, vous recevrez un courriel contenant
user_password_changed=Le mot de passe de %s a \u00E9t\u00E9 mis \u00E0 jour.
user_password_notchanged=\u00C9chec lors du changement de mot de passe de %s. Contactez le support.
user_password_invalid_changekey=%s est une cl\u00E9 invalide pour %s. Les cl\u00E9s ne sont valides que pendant une journ\u00E9e.
user_with_that_email_found=Un utilisateur avec cette adresse email ou ce nom d''utilisateur existe d\u00E9j\u00E0.
user_with_that_username_found=Un utilisateur avec cette adresse email ou ce nom d''utilisateur existe d\u00E9j\u00E0.
user_with_that_email_username_found=Un utilisateur avec cette adresse email ou ce nom d''utilisateur existe d\u00E9j\u00E0.
register_email_admin_subject=%s / Cr\u00E9ation de compte pour %s en tant que %s
register_email_admin_message=Cher administrateur,\n\
L'utilisateur %s vient de demander une cr\u00E9ation de compte pour %s.\n\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ public void validate(Object target, Errors errors) {
}

UserRepository userRepository = ApplicationContextHolder.get().getBean(UserRepository.class);
if (userRepository.findOneByEmail(userRegisterDto.getEmail()) != null) {
errors.rejectValue("", "user_with_that_email_found", "A user with this email or username already exists.");
if ((userRepository.findOneByEmail(userRegisterDto.getEmail()) != null) ||
(!userRepository.findByUsernameIgnoreCase(userRegisterDto.getEmail()).isEmpty())) {
errors.rejectValue("", "user_with_that_email_username_found", "A user with this email or username already exists.");
}

if (userRepository.findByUsernameIgnoreCase(userRegisterDto.getEmail()).size() != 0) {
errors.rejectValue("", "user_with_that_username_found", "A user with this email or username already exists.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ user_password_changed='%s' password was updated.
user_password_notchanged=A problem occurred trying to change '%s' password. Contact the helpdesk.
user_password_invalid_changekey='%s' is an invalid change key for '%s'. Change keys are only valid for one day.
user_registered=User '%s' registered.
user_with_that_email_found=A user with this email or username already exists.
user_with_that_username_found=A user with this email or username already exists.
user_with_that_email_username_found=A user with this email or username already exists.
register_email_admin_subject=%s / New account for %s as %s
register_email_admin_message=Dear Admin,\n\
Newly registered user %s has requested %s access for %s.\n\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ user_password_sent=Si l''utilisateur existe, vous recevrez un courriel contenant
user_password_changed=Le mot de passe de %s a \u00E9t\u00E9 mis \u00E0 jour.
user_password_notchanged=\u00C9chec lors du changement de mot de passe de %s. Contactez le support.
user_password_invalid_changekey=%s est une cl\u00E9 invalide pour %s. Les cl\u00E9s ne sont valides que pendant une journ\u00E9e.
user_with_that_email_found=Un utilisateur avec cette adresse email ou ce nom d''utilisateur existe d\u00E9j\u00E0.
user_with_that_username_found=Un utilisateur avec cette adresse email ou ce nom d''utilisateur existe d\u00E9j\u00E0.
user_with_that_email_username_found=Un utilisateur avec cette adresse email ou ce nom d''utilisateur existe d\u00E9j\u00E0.
register_email_admin_subject=%s / Cr\u00E9ation de compte pour %s en tant que %s
register_email_admin_message=Cher administrateur,\n\
L'utilisateur %s vient de demander une cr\u00E9ation de compte pour %s.\n\
Expand Down

0 comments on commit 82fda12

Please sign in to comment.