use of org.mifos.dto.domain.ChangePasswordRequest in project head by mifos.
the class ChangePasswordController method processFormSubmit.
@RequestMapping(method = RequestMethod.POST)
public String processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") @Valid ChangePasswordFormBean formBean, BindingResult result, SessionStatus status, HttpServletRequest request) {
String viewName = HOME_PAGE;
if (CANCEL_PARAM_VALUE.equals(cancel)) {
viewName = REDIRECT_AND_LOGOUT;
status.setComplete();
} else if (result.hasErrors()) {
viewName = "changePassword";
} else {
try {
ChangePasswordRequest changePasswordRequest = new ChangePasswordRequest(formBean.getUsername(), formBean.getOldPassword(), formBean.getNewPassword());
loginServiceFacade.changePassword(changePasswordRequest);
status.setComplete();
} catch (BusinessRuleException e) {
ObjectError error = new ObjectError("passwordUsed", messageSource.getMessage("error.passwordAlreadyUsedException", null, RequestContextUtils.getLocale(request)));
result.addError(error);
viewName = "changePassword";
}
}
return viewName;
}
Aggregations