Skip to content

Commit

Permalink
Updated user registration to check for existing email.
Browse files Browse the repository at this point in the history
  • Loading branch information
kvb2univpitt committed Aug 19, 2015
1 parent 52b7748 commit 52c4363
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,23 @@ public String registerWebUser(
final HttpServletRequest request) {
String username = userRegistration.getUsername();
if (userAccountService.findByUsername(username) == null) {
try {
userService.registerNewUser(userRegistration, workspace, request.getRequestURL().toString());
String msg = "Thank you for registering."
+ "Check your email to verify and activate your account.";
redirectAttributes.addFlashAttribute("successMsg", msg);
} catch (Exception exception) {
LOGGER.warn(
String.format("Unable to register new user account for %s.", username),
exception);
redirectAttributes.addFlashAttribute("errorMsg", String.format("Unable to create account for '%s'.", username));
String email = userRegistration.getEmail();
if (userAccountService.findUserAccountByEmail(email) == null) {
try {
userService.registerNewUser(userRegistration, workspace, request.getRequestURL().toString());
String msg = "Thank you for registering."
+ "Check your email to verify and activate your account.";
redirectAttributes.addFlashAttribute("successMsg", msg);
} catch (Exception exception) {
LOGGER.warn(
String.format("Unable to register new user account for %s.", username),
exception);
redirectAttributes.addFlashAttribute("errorMsg", String.format("Unable to create account for '%s'.", username));
}
} else {
redirectAttributes.addFlashAttribute("errorMsg", String.format("This email '%s' has already been registered.", email));
}

} else {
redirectAttributes.addFlashAttribute("errorMsg", String.format("Username '%s' is already taken.", username));
}
Expand Down

0 comments on commit 52c4363

Please sign in to comment.