From b78e088a5bbc0c9061e67ec5d4f2afa9613a6e94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 29 Aug 2016 17:13:06 +0200 Subject: [PATCH] Please cherry-pick: - nope, was not working, the login-controller still needs it to compare it with current user's --- .../JobsUserPasswordWebRequestBean.java | 24 ++++-------------- .../JobsUserPasswordWebRequestController.java | 25 ++++++++----------- .../user/user_enter_current_password.tpl | 11 +------- web/user/login_change_password.xhtml | 4 +-- web/user/login_change_personal_data.xhtml | 4 +-- 5 files changed, 18 insertions(+), 50 deletions(-) diff --git a/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestBean.java index ae3eafc4..03130831 100644 --- a/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestBean.java @@ -65,11 +65,6 @@ public class JobsUserPasswordWebRequestBean extends BaseJobsController implement */ private final UserSessionBeanRemote userBean; - /** - * Current password (for confirmation of password change) - */ - private String userCurrentPassword; - /** * Login controller (bean) */ @@ -125,7 +120,7 @@ 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", "ERROR_USER_CURRENT_PASSWORD_MISMATCHING"); //NOI18N @@ -143,7 +138,7 @@ public class JobsUserPasswordWebRequestBean extends BaseJobsController implement // 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", "ERROR_USER_NEW_PASSWORD_SAME_AS_CURRENT"); //NOI18N @@ -193,16 +188,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 +208,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) && diff --git a/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestController.java b/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestController.java index 3104b9fb..a47f00b5 100644 --- a/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/user/password/JobsUserPasswordWebRequestController.java @@ -41,20 +41,6 @@ public interface JobsUserPasswordWebRequestController extends Serializable { */ void setUserPassword (final String userPassword); - /** - * Getter for current unencrypted user password - *

- * @return Current unencrypted user password - */ - String getUserCurrentPassword (); - - /** - * Setter for current unencrypted user password - *

- * @param userCurrentPassword Current unencrypted user password - */ - void setUserCurrentPassword (final String userCurrentPassword); - /** * Getter for unencrypted user password repeated *

@@ -70,7 +56,16 @@ public interface JobsUserPasswordWebRequestController extends Serializable { void setUserPasswordRepeat (final String userPasswordRepeat); /** - * Changes logged-in user's password. It must not match with current password and should not appear in password history list for X (configurable) entries. + * Checks whether all required "password-change fields" are set. + *

+ * @return Whether the required fields are set + */ + boolean isRequiredChangePasswordSet (); + + /** + * Changes logged-in user's password. It must not match with current + * password and should not appear in password history list for X + * (configurable) entries. *

* @return Redirect outcome */ diff --git a/web/WEB-INF/templates/login/user/user_enter_current_password.tpl b/web/WEB-INF/templates/login/user/user_enter_current_password.tpl index 8c6e2ece..15dda796 100644 --- a/web/WEB-INF/templates/login/user/user_enter_current_password.tpl +++ b/web/WEB-INF/templates/login/user/user_enter_current_password.tpl @@ -5,14 +5,6 @@ xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> - - - - - - - -

@@ -25,7 +17,7 @@
- +
@@ -38,5 +30,4 @@ - diff --git a/web/user/login_change_password.xhtml b/web/user/login_change_password.xhtml index ea8d8f73..dc647b75 100644 --- a/web/user/login_change_password.xhtml +++ b/web/user/login_change_password.xhtml @@ -70,9 +70,7 @@ - - - +