Skip to content

Commit

Permalink
Provide detailed error message when attempting to create user of exis…
Browse files Browse the repository at this point in the history
…ting email or login (fixes #674)
  • Loading branch information
marcelmay committed Jan 28, 2024
1 parent 47eefcd commit 91da8b3
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ public GreenMailUser getUserByEmail(String email) {

public GreenMailUser createUser(String email, String login, String password) throws UserException {
log.debug("Creating user {}", email);
// Check that user does not exist
if(getUserByEmail(email)!=null) {
throw new UserException("Can not create new user as another user of same email '" + email +
"' already exists");
}
if(getUser(login)!=null) {
throw new UserException("Can not create new user as another user of same login '" + login +
"' already exists");
}
GreenMailUser user = new UserImpl(email, login, password, imapHostManager);
user.create();
loginToUser.put(normalizerUserName(user.getLogin()), user);
Expand Down

0 comments on commit 91da8b3

Please sign in to comment.