From 4aac4ab6bc803d8d0a5168bdcd900a4cba471b5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 29 Aug 2016 15:28:12 +0200 Subject: [PATCH] Please cherry-pick: - rewrote exceptions to nice faces messages - added missing 18n strings --- .../user/JobsAdminUserWebRequestBean.java | 22 ++++++++++++++----- .../localization/bundle_de_DE.properties | 3 +++ .../localization/bundle_en_US.properties | 3 +++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java index 1776e0e5..38550243 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java @@ -413,20 +413,30 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J // Not all required fields are set throw new IllegalArgumentException("this.userName is empty"); //NOI18N } else if (((!this.getUserPassword().isEmpty()) || (!this.getUserPasswordRepeat().isEmpty())) && (!this.isSamePasswordEntered())) { - // Not same password entered + // Clear password fields this.setUserPassword(null); this.setUserPasswordRepeat(null); - // Throw exception - throw new FaceletException("Not same password entered"); //NOI18N + // Not same password entered + this.showFacesMessage("form_edit_user:userPassword", "ADMIN_USER_PASSWORD_REPEAT_DIFFERENT"); //NOI18N + return ""; //NOI18N } else if ((!Objects.equals(user.getUserName(), this.getUserName())) && (this.userBean.ifUserNameExists(this.getUserName()))) { + // Clear all fields + this.clear(); + // User name already exists - throw new FaceletException(new UserNameAlreadyRegisteredException(this.getUserName())); + this.showFacesMessage("form_edit_user:userName", "ADMIN_USER_NAME_ALREADY_EXISTS"); //NOI18N + return ""; //NOI18N } else if (this.isSamePasswordEntered()) { // Same password entered, create container - if (UserUtils.ifPasswordMatches(new UserLoginContainer(user, this.getUserPassword()))) { + if ((Objects.equals(user.getUserMustChangePassword(), this.getUserMustChangePassword())) && (UserUtils.ifPasswordMatches(new UserLoginContainer(user, this.getUserPassword())))) { + // Clear password fields + this.setUserPassword(null); + this.setUserPasswordRepeat(null); + // Same password entered - throw new FaceletException("Same password as stored entered."); //NOI18N + this.showFacesMessage("form_edit_user:userPassword", "ADMIN_USER_ENTERED_SAME_AS_OLD_PASSWORD"); //NOI18N + return ""; //NOI18N } // Encrypt password diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 09f78d14..726aaa69 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -776,3 +776,6 @@ ADMIN_DELETE_USER_NOTICE=Durch das L\u00f6schen des Benutzeraccounts werden nur ADMIN_ACTIVITY_ADMIN_DELETED_USER_ACCOUNT=Benutzeraccount gel\u00f6scht vom Administrator. USER_ACTIVITY_ADMIN_DELETED_USER_ACCOUNT=Ihr Benutzeraccount wurde von einem Administrator gel\u00f6scht. ADMIN_USER_DELETE_REASON=L\u00f6schgrund: (optional) +ADMIN_USER_PASSWORD_REPEAT_DIFFERENT=Your both entered passwords don't match. +ADMIN_USER_NAME_ALREADY_EXISTS=Your entered user name does already exist in other user account. +ADMIN_USER_ENTERED_SAME_AS_OLD_PASSWORD=You have not changed the password (same as stored entered) diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 98308e24..4987f486 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -777,3 +777,6 @@ ADMIN_DELETE_USER_NOTICE=By deleting the user's account, only user data is delet ADMIN_ACTIVITY_ADMIN_DELETED_USER_ACCOUNT=User account has been deleted by administrator. USER_ACTIVITY_ADMIN_DELETED_USER_ACCOUNT=Your account has been deleted by an administrator. ADMIN_USER_DELETE_REASON=Delete reason: (optional) +ADMIN_USER_PASSWORD_REPEAT_DIFFERENT=Die beiden von Ihnen eingegebenen Passw\u00f6rter stimmen nicht \u00fcberein. +ADMIN_USER_NAME_ALREADY_EXISTS=Der von Ihnen eingegebene Benutzername existiert bereits (anderes Benutzeraccount). +ADMIN_USER_ENTERED_SAME_AS_OLD_PASSWORD=Sie haben das Passwort nicht ge\u00e4ndert (selibiges wie gespeichertes). -- 2.39.5