@RequestMapping(value = "/change", method = RequestMethod.POST) public String changePassword( @Valid final UpdatePwdForm form, final BindingResult bindingResult, final Model model, final RedirectAttributes redirectModel) throws CMSItemNotFoundException { if (bindingResult.hasErrors()) { prepareErrorMessage(model, UPDATE_PWD_CMS_PAGE); return ControllerConstants.Views.Pages.Password.PasswordResetChangePage; } if (!StringUtils.isBlank(form.getToken())) { try { customerFacade.updatePassword(form.getToken(), form.getPwd()); GlobalMessages.addFlashMessage( redirectModel, GlobalMessages.CONF_MESSAGES_HOLDER, "account.confirmation.password.updated"); } catch (final TokenInvalidatedException e) { GlobalMessages.addFlashMessage( redirectModel, GlobalMessages.ERROR_MESSAGES_HOLDER, "updatePwd.token.invalidated"); } catch (final RuntimeException e) { GlobalMessages.addFlashMessage( redirectModel, GlobalMessages.ERROR_MESSAGES_HOLDER, "updatePwd.token.invalid"); } } return REDIRECT_LOGIN; }
@RequestMapping(value = "/change", method = RequestMethod.GET) public String getChangePassword( @RequestParam(required = false) final String token, final Model model) throws CMSItemNotFoundException { if (StringUtils.isBlank(token)) { return REDIRECT_HOME; } final UpdatePwdForm form = new UpdatePwdForm(); form.setToken(token); model.addAttribute(form); storeCmsPageInModel(model, getContentPageForLabelOrId(UPDATE_PWD_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(UPDATE_PWD_CMS_PAGE)); model.addAttribute( WebConstants.BREADCRUMBS_KEY, resourceBreadcrumbBuilder.getBreadcrumbs("updatePwd.title")); return ControllerConstants.Views.Pages.Password.PasswordResetChangePage; }