use of org.hibernate.validator.internal.constraintvalidators.bv.EmailValidator in project jprime by bgjug.
the class CfpController method validateEmail.
private String validateEmail(BindingResult bindingResult, Submission submission, Model model, String email, String role) {
EmailValidator emailValidator = new EmailValidator();
if (!StringUtils.isEmpty(email) && emailValidator.isValid(email, null)) {
// Email is valid
return null;
}
bindingResult.addError(new FieldError("submission", role + ".email", "Invalid Email!"));
return goToCFP(submission, model);
}
use of org.hibernate.validator.internal.constraintvalidators.bv.EmailValidator in project jprime by bgjug.
the class UserController method resetPassword.
@RequestMapping(value = "/resetPassword", method = RequestMethod.POST)
public String resetPassword(@RequestParam(value = "email") String email, Model model, final RedirectAttributes redirectAttrs) {
EmailValidator mailValidator = new EmailValidator();
if (!mailValidator.isValid(email, null)) {
model.addAttribute("error_msg", "Please, enter a valid mail address");
return RESET_PASSWORD_JSP;
}
User user = getUserRepository().findUserByEmail(email);
if (user != null) {
String tokenId = resetPassService.createNewToken(user);
try {
String mailContent = buildResetMailContent(user, tokenId, "/resetPasswordMail.html");
String mailTitle = "Reset your JPrime password";
mailService.sendEmail(email, mailTitle, mailContent);
} catch (MessagingException | IOException | URISyntaxException e) {
logger.error("Error while sending ResetPassword Mail to " + user, e);
}
}
redirectAttrs.addFlashAttribute("sent_to_email", email);
return "redirect:/resetPassword";
}
Aggregations