*/
@Override
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors)
throws Exception {
PasswordReset passwd = (PasswordReset) command;
boolean success=false;
// let's check if password reset session is properly set.
String secureCode = (String) request.getSession().getAttribute(ConfirmPasswordResetController.SECURE_SESSION_KEY);
if (!StringUtil.isEmpty(secureCode) && secureCode.startsWith(ConfirmPasswordResetController.SECURE_SESSION_CODE) &&
(passwd.getEmailAddress().equals(secureCode.substring(ConfirmPasswordResetController.SECURE_SESSION_CODE.length())))) {
success = userService.resetPassword(passwd);
}
if (success) {
_log.info("Password changed. "+passwd.getEmailAddress() +" has successfully changed password.");
Map<String,String> model = new HashMap<String,String>();
model.put("message", "msg.password-change-successful");
model.put("title", "label.forgot-password");
return new ModelAndView(getSuccessView(), model);
} else {
Map<String,String> model = new HashMap<String,String>();
_log.info("Unauthorized access to reset password using email ["+passwd.getEmailAddress()+
"] and secureCode ["+secureCode+"] from IP "+request.getRemoteAddr());
model.put("message", "error.unauthorized-access-to-change-password");
model.put("title", "label.forgot-password");
return new ModelAndView(getSuccessView(), model);
}