small changes

This commit is contained in:
eugenp 2015-02-11 14:28:03 +02:00
parent 7539be6c78
commit 99170431c0
1 changed files with 25 additions and 0 deletions

View File

@ -121,6 +121,7 @@ public class RegistrationController {
public String resendRegistrationToken(final HttpServletRequest request, final Model model, @RequestParam("token") final String existingToken) { public String resendRegistrationToken(final HttpServletRequest request, final Model model, @RequestParam("token") final String existingToken) {
final Locale locale = request.getLocale(); final Locale locale = request.getLocale();
final VerificationToken newToken = userService.generateNewVerificationToken(existingToken); final VerificationToken newToken = userService.generateNewVerificationToken(existingToken);
final User user = userService.getUser(newToken.getToken()); final User user = userService.getUser(newToken.getToken());
try { try {
final String appUrl = request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); final String appUrl = request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
@ -134,6 +135,30 @@ public class RegistrationController {
model.addAttribute("message", e.getLocalizedMessage()); model.addAttribute("message", e.getLocalizedMessage());
return "redirect:/login.html?lang=" + locale.getLanguage(); return "redirect:/login.html?lang=" + locale.getLanguage();
} }
model.addAttribute("message", messages.getMessage("message.resendToken", null, locale));
return "redirect:/login.html?lang=" + locale.getLanguage();
}
@RequestMapping(value = "/user/resendRegistrationToken2", method = RequestMethod.GET)
public String resendRegistrationToken2(final HttpServletRequest request, final Model model, @RequestParam("token") final String existingToken) {
final Locale locale = request.getLocale();
final VerificationToken newToken = userService.generateNewVerificationToken(existingToken);
final User user = userService.getUser(newToken.getToken());
try {
final String appUrl = request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
final SimpleMailMessage email = constructResetVerificationTokenEmail(appUrl, request.getLocale(), newToken, user);
mailSender.send(email);
} catch (final MailAuthenticationException e) {
LOGGER.debug("MailAuthenticationException", e);
return "redirect:/emailError.html?lang=" + locale.getLanguage();
} catch (final Exception e) {
LOGGER.debug(e.getLocalizedMessage(), e);
model.addAttribute("message", e.getLocalizedMessage());
return "redirect:/login.html?lang=" + locale.getLanguage();
}
model.addAttribute("message", messages.getMessage("message.resendToken", null, locale)); model.addAttribute("message", messages.getMessage("message.resendToken", null, locale));
return "redirect:/login.html?lang=" + locale.getLanguage(); return "redirect:/login.html?lang=" + locale.getLanguage();
} }