String oldPassword = request.getParameter(Constants.OLD_PASSWORD);
String newPassword = request.getParameter(Constants.NEW_PASSWORD);
String confirmPassword = request.getParameter(Constants.CONFIRM_PASSWORD);
Feedback feedback = null;
if(oldPassword==null || newPassword==null || confirmPassword==null)
feedback = Feedback.CHANGE_PASSWORD_REQUIRED;
else if(oldPassword.equals(newPassword))
feedback = Feedback.NO_CHANGES_MADE;
else if(newPassword.equals(confirmPassword))
{
if(cred.getPassword().equals(oldPassword))
{
cred.setPassword(newPassword);
if(CredentialDao.executeUpdate())
{
request.setAttribute(Constants.MSG, Feedback.PASSWORD_CHANGED.getMsg());
dispatchToView(null, rc, getWebContext());
return;
}
}
else
feedback = Feedback.PASSWORD_INCORRECT;
}
else
feedback = Feedback.PASSWORD_DID_NOT_MATCH;
if(feedback==null)
feedback = Feedback.COULD_NOT_UPDATE_ACCOUNT;
request.setAttribute(Constants.MSG, feedback.getMsg());
dispatchToFormChangePassword(rc, getWebContext());
}