diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/GenericResponse.java b/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/GenericResponse.java new file mode 100644 index 0000000000..fd2869cf97 --- /dev/null +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/GenericResponse.java @@ -0,0 +1,23 @@ +package org.baeldung.web.controller; + +public class GenericResponse { + + private String message; + + public GenericResponse() { + super(); + } + + public GenericResponse(final String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java b/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java index 616ff23f98..b7bbeab977 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java @@ -151,13 +151,14 @@ public class RegistrationController { } @RequestMapping(value = "/user/resendRegistrationToken2", method = RequestMethod.GET) - public @ResponseBody String resendRegistrationToken2(final HttpServletRequest request, final Model model, @RequestParam("token") final String existingToken) throws JsonProcessingException, NoSuchMessageException { + public @ResponseBody GenericResponse resendRegistrationToken2(final HttpServletRequest request, @RequestParam("token") final String existingToken) { final VerificationToken newToken = userService.generateNewVerificationToken(existingToken); final User user = userService.getUser(newToken.getToken()); final String appUrl = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); final SimpleMailMessage email = constructResetVerificationTokenEmail(appUrl, request.getLocale(), newToken, user); mailSender.send(email); - return new ObjectMapper().writeValueAsString(messages.getMessage("message.resendToken", null, request.getLocale())); + + return new GenericResponse(messages.getMessage("message.resendToken", null, request.getLocale())); } @RequestMapping(value = "/user/resetPassword", method = RequestMethod.POST) @@ -187,9 +188,10 @@ public class RegistrationController { } @RequestMapping(value = "/user/resetPassword2", method = RequestMethod.POST) - public @ResponseBody String resetPassword2(final HttpServletRequest request, final Model model, @RequestParam("email") final String userEmail) throws JsonProcessingException, NoSuchMessageException { + public @ResponseBody String resetPassword2(final HttpServletRequest request, @RequestParam("email") final String userEmail) throws JsonProcessingException, NoSuchMessageException { final User user = userService.findUserByEmail(userEmail); if (user == null) { + // throw new NotFoundExceptions(messages.getMessage("message.userNotFound", null, request.getLocale())); // 404 return new ObjectMapper().writeValueAsString(messages.getMessage("message.userNotFound", null, request.getLocale())); } diff --git a/spring-security-oauth/src/main/java/org/baeldung/config/SessionListener.java b/spring-security-oauth/src/main/java/org/baeldung/config/SessionListener.java index 128522b89f..95e41714f9 100644 --- a/spring-security-oauth/src/main/java/org/baeldung/config/SessionListener.java +++ b/spring-security-oauth/src/main/java/org/baeldung/config/SessionListener.java @@ -8,7 +8,7 @@ public class SessionListener implements HttpSessionListener { @Override public void sessionCreated(HttpSessionEvent event) { System.out.println("==== Session is created ===="); - event.getSession().setMaxInactiveInterval(1 * 60); + event.getSession().setMaxInactiveInterval(30 * 60); } @Override