ResetPasswordAction action, ExecutionContext executionContext) {
final String emailAddress = action.getResetPasswordData().getEmailAddress();
try {
User user = metaProjectManager.getUser(emailAddress);
if(user == null) {
return new ResetPasswordResult(INVALID_EMAIL_ADDRESS);
}
if(user.getEmail() == null) {
return new ResetPasswordResult(INVALID_EMAIL_ADDRESS);
}
if(user.getEmail().compareToIgnoreCase(emailAddress) != 0) {
return new ResetPasswordResult(INVALID_EMAIL_ADDRESS);
}
String pwd = IdUtil.getBase62UUID();
user.setPassword(pwd);
mailer.sendEmail(emailAddress, pwd);
return new ResetPasswordResult(SUCCESS);
} catch (Exception e) {
logger.info("Could not reset the user password " +
"associated with the email " +
"address %s. The following " +
"error occurred: %s.", emailAddress, e.getMessage());
return new ResetPasswordResult(INTERNAL_ERROR);
}
}