@RequestMapping(value = "/update-password", method = RequestMethod.POST) @RequireHardLogIn public String updatePassword( final UpdatePasswordForm updatePasswordForm, final BindingResult bindingResult, final Model model, final RedirectAttributes redirectAttributes) throws CMSItemNotFoundException { getPasswordValidator().validate(updatePasswordForm, bindingResult); if (!bindingResult.hasErrors()) { if (updatePasswordForm.getNewPassword().equals(updatePasswordForm.getCheckNewPassword())) { try { customerFacade.changePassword( updatePasswordForm.getCurrentPassword(), updatePasswordForm.getNewPassword()); } catch (final PasswordMismatchException localException) { bindingResult.rejectValue( "currentPassword", "profile.currentPassword.invalid", new Object[] {}, "profile.currentPassword.invalid"); } } else { bindingResult.rejectValue( "checkNewPassword", "validation.checkPwd.equals", new Object[] {}, "validation.checkPwd.equals"); } } if (bindingResult.hasErrors()) { GlobalMessages.addErrorMessage(model, "form.global.error"); storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile.updatePasswordForm")); return ControllerConstants.Views.Pages.Account.AccountChangePasswordPage; } else { GlobalMessages.addFlashMessage( redirectAttributes, GlobalMessages.CONF_MESSAGES_HOLDER, "text.account.confirmation.password.updated", null); return REDIRECT_TO_PROFILE_PAGE; } }