import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
/**
- * A user password (change) bean (controller)
+ * A user password (change) controller (bean)
* <p>
* @author Roland Haeder<roland@mxchange.org>
*/
private final UserSessionBeanRemote userBean;
/**
- * Current password (for confirmation of password change)
- */
- private String userCurrentPassword;
-
- /**
- * Login bean (controller)
+ * Login controller (bean)
*/
@Inject
private JobsUserLoginWebSessionController userLoginController;
} else if (!this.featureController.isFeatureEnabled("change_user_password")) { //NOI18N
// Editing is not allowed
throw new IllegalStateException("User tried to change password."); //NOI18N
- } else if (!UserUtils.ifPasswordMatches(this.getUserCurrentPassword(), this.userLoginController.getLoggedInUser())) {
+ } else if (!UserUtils.ifPasswordMatches(this.userLoginController.getUserCurrentPassword(), this.userLoginController.getLoggedInUser())) {
// Password mismatches
- this.showFacesMessage("form_user_change_password:userCurrentPassword", "Entered current password does not matched stored password."); //NOI18N
+ this.showFacesMessage("form_user_change_password:userCurrentPassword", "ERROR_USER_CURRENT_PASSWORD_MISMATCHING"); //NOI18N
// Clear bean
this.clear();
return ""; //NOI18N
} else if (!Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())) {
// Both entered passwords don't match
- this.showFacesMessage("form_user_change_password:userPasswordRepeat", "Entered new passwords mismatch."); //NOI18N
+ this.showFacesMessage("form_user_change_password:userPasswordRepeat", "ERROR_USER_NEW_PASSWORDS_MISMATCH"); //NOI18N
// Clear bean
this.clear();
// No redirect
return ""; //NOI18N
- } else if (Objects.equals(this.getUserCurrentPassword(), this.getUserPassword())) {
+ } else if (Objects.equals(this.userLoginController.getUserCurrentPassword(), this.getUserPassword())) {
// New password matches current
- this.showFacesMessage("form_user_change_password:userPassword", "Entered new password is same as current password."); //NOI18N
+ this.showFacesMessage("form_user_change_password:userPassword", "ERROR_USER_NEW_PASSWORD_SAME_AS_CURRENT"); //NOI18N
// Clear bean
this.clear();
return ""; //NOI18N
} else if (this.userLoginController.isPasswordInHistory(this.getUserPassword())) {
// Is already in list (to old passwords are ignored)
- this.showFacesMessage("form_user_change_password:userPassword", "Entered new password is has already been used some time ago."); //NOI18N
+ this.showFacesMessage("form_user_change_password:userPassword", "ERROR_USER_NEW_PASSWORD_ALREADY_ENTERED"); //NOI18N
// Clear bean
this.clear();
String encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
// Set it in user
+ user.setUserMustChangePassword(Boolean.FALSE);
user.setUserEncryptedPassword(encryptedPassword);
try {
return "login_data_saved"; //NOI18N
}
- @Override
- public String getUserCurrentPassword () {
- return this.userCurrentPassword;
- }
-
- @Override
- public void setUserCurrentPassword (final String userCurrentPassword) {
- this.userCurrentPassword = userCurrentPassword;
- }
-
@Override
public String getUserPassword () {
return this.userPassword;
this.userPasswordRepeat = userPasswordRepeat;
}
+ @Override
public boolean isRequiredChangePasswordSet () {
// Is all data set?
- return ((this.getUserCurrentPassword() != null) &&
- (!this.getUserCurrentPassword().isEmpty()) &&
+ return ((this.userLoginController.getUserCurrentPassword() != null) &&
+ (!this.userLoginController.getUserCurrentPassword().isEmpty()) &&
(this.getUserPassword() != null) &&
(!this.getUserPassword().isEmpty()) &&
(this.getUserPasswordRepeat() != null) &&