]> git.mxchange.org Git - jjobs-war.git/blobdiff - src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestBean.java
Please cherry-pick:
[jjobs-war.git] / src / java / org / mxchange / jjobs / beans / user / password / JobsUserPasswordWebRequestBean.java
index d5cc6da01fdb8620d2776574428c0bdac40495b2..4d5d4c8f39c2af3ccfced128cb4dbcd514e38a7a 100644 (file)
@@ -41,7 +41,7 @@ import org.mxchange.jusercore.model.user.UserUtils;
 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>
  */
@@ -66,12 +66,7 @@ public class JobsUserPasswordWebRequestBean extends BaseJobsController implement
        private final UserSessionBeanRemote userBean;
 
        /**
-        * Current password (for confirmation of password change)
-        */
-       private String userCurrentPassword;
-
-       /**
-        * Login bean (controller)
+        * Login controller (bean)
         */
        @Inject
        private JobsUserLoginWebSessionController userLoginController;
@@ -125,9 +120,9 @@ public class JobsUserPasswordWebRequestBean extends BaseJobsController implement
                } 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();
@@ -136,16 +131,16 @@ public class JobsUserPasswordWebRequestBean extends BaseJobsController implement
                        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();
@@ -154,7 +149,7 @@ public class JobsUserPasswordWebRequestBean extends BaseJobsController implement
                        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();
@@ -170,6 +165,7 @@ public class JobsUserPasswordWebRequestBean extends BaseJobsController implement
                String encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
 
                // Set it in user
+               user.setUserMustChangePassword(Boolean.FALSE);
                user.setUserEncryptedPassword(encryptedPassword);
 
                try {
@@ -193,16 +189,6 @@ public class JobsUserPasswordWebRequestBean extends BaseJobsController implement
                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;
@@ -223,10 +209,11 @@ public class JobsUserPasswordWebRequestBean extends BaseJobsController implement
                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) &&