]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sun, 30 Jul 2017 20:16:54 +0000 (22:16 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 30 Jul 2017 20:21:27 +0000 (22:21 +0200)
- don't clear user names or passwords directly, let an event do it

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebSessionBean.java
src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebSessionController.java
src/java/org/mxchange/jfinancials/beans/user/register/FinancialsUserRegisterWebSessionBean.java

index 262ad200d61d0a3a7d637a5b1f7f3b6ac1f8aa64..407deacc7b8251799f5890659aa92128390ab4bf 100644 (file)
@@ -39,6 +39,8 @@ import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationC
 import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController;
 import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.clear.password.ObservableClearUserPasswordEvent;
+import org.mxchange.jusercore.events.user.clear.username.ObservableClearUserNameEvent;
 import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
 import org.mxchange.jusercore.events.user.helper.created.ObservableHelperCreatedUserEvent;
 import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
@@ -552,17 +554,36 @@ public class FinancialsUserWebSessionBean extends BaseFinancialsController imple
                return this.visibleUserList;
        }
 
-       @Override
-       public void clearUserName () {
+       /**
+        * Event observer for when a user name should be cleared
+        * <p>
+        * @param event Event being fired
+        */
+       public void clearUserNameEvent (@Observes final ObservableClearUserNameEvent event) {
+               // Is it valid?
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null");
+               }
+
                // Clear it
-               this.setUserName(null);
+               this.clearUserName();
        }
 
-       @Override
-       public void clearUserPasswords () {
-               // Clear both
-               this.setUserPassword(null);
-               this.setUserPasswordRepeat(null);
+       /**
+        * Event observer for when both user passwords should be cleared
+        * <p>
+        * @param event Event being fired
+        */
+       public void clearUserPasswordEvent (@Observes final ObservableClearUserPasswordEvent event) {
+               // Is it valid?
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null");
+               }
+
+               // Clear it
+               this.clearUserPasswords();
        }
 
        @Override
@@ -1035,6 +1056,23 @@ public class FinancialsUserWebSessionBean extends BaseFinancialsController imple
                this.clearUserPasswords();
        }
 
+       /**
+        * Clears user name
+        */
+       private void clearUserName () {
+               // Clear it
+               this.setUserName(null);
+       }
+
+       /**
+        * Clears both user passwords
+        */
+       private void clearUserPasswords () {
+               // Clear both
+               this.setUserPassword(null);
+               this.setUserPasswordRepeat(null);
+       }
+
        /**
         * Copies given user into the controller
         * <p>
index bf8b51b744230dd5989ef7796cd74330a1f9bb04..b0b9ac8178adc088ac86fb36495430b5d02e7653 100644 (file)
@@ -44,16 +44,6 @@ public interface FinancialsUserWebSessionController extends Serializable {
         */
        String getUserPassword ();
 
-       /**
-        * Clears both user passwords
-        */
-       void clearUserPasswords ();
-
-       /**
-        * Clears user name
-        */
-       void clearUserName ();
-
        /**
         * Checks if both user passwords are left empty and if this is enabled
         * (allowed) in context parameter. If true, the calling bean should create a
index 7068c5dcd4aa5f81abba878187e506aad7036c82..553ef3a85a534bf6e830bee2b8a76a0453fec49d 100644 (file)
@@ -34,6 +34,10 @@ import org.mxchange.jfinancials.beans.contact.FinancialsContactWebSessionControl
 import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
 import org.mxchange.jfinancials.beans.user.FinancialsAdminUserWebRequestController;
 import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;
+import org.mxchange.jusercore.events.user.clear.password.ClearUserPasswordEvent;
+import org.mxchange.jusercore.events.user.clear.password.ObservableClearUserPasswordEvent;
+import org.mxchange.jusercore.events.user.clear.username.ClearUserNameEvent;
+import org.mxchange.jusercore.events.user.clear.username.ObservableClearUserNameEvent;
 import org.mxchange.jusercore.exceptions.DataRepeatMismatchException;
 import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
 import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
@@ -98,6 +102,20 @@ public class FinancialsUserRegisterWebSessionBean extends BaseFinancialsControll
        @Any
        private Event<ObservableUpdatedUserPasswordEvent> userPasswordChangedEvent;
 
+       /**
+        * An event being fired when a user name should be cleared
+        */
+       @Inject
+       @Any
+       private Event<ObservableClearUserNameEvent> clearUserNameEvent;
+
+       /**
+        * An event being fired when a user password should be cleared
+        */
+       @Inject
+       @Any
+       private Event<ObservableClearUserPasswordEvent> clearUserPasswordEvent;
+
        /**
         * An event being fired when a new user has registered
         */
@@ -145,8 +163,10 @@ public class FinancialsUserRegisterWebSessionBean extends BaseFinancialsControll
                                // User name is already used, should not happen here
                                throw new FaceletException(new UserNameAlreadyRegisteredException(user));
                        } else {
-                               // May happen here, reset field
-                               this.userController.clearUserName();
+                               // May happen here, fire event
+                               this.clearUserNameEvent.fire(new ClearUserNameEvent());
+
+                               // Output message
                                this.showFacesMessage("form_register_single:userName", "ERROR_USER_NAME_ALREADY_USED"); //NOI18N
                                return ""; //NOI18N
                        }
@@ -254,7 +274,9 @@ public class FinancialsUserRegisterWebSessionBean extends BaseFinancialsControll
                        throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N
                } else if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userController.isUserNameRegistered(user))) { //NOI18N
                        // User name is already used, so clear it
-                       this.userController.clearUserName();
+                       this.clearUserNameEvent.fire(new ClearUserNameEvent());
+
+                       // Output message
                        this.showFacesMessage("form_register_page1:userName", "ERROR_USER_NAME_ALREADY_USED"); //NOI18N
                        return ""; //NOI18N
                } else if (!this.contactController.isSameEmailAddressEntered()) {
@@ -266,7 +288,7 @@ public class FinancialsUserRegisterWebSessionBean extends BaseFinancialsControll
                        // Is multi-page enabled?
                        if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
                                // Unset both
-                               this.userController.clearUserPasswords();
+                               this.clearUserPasswordEvent.fire(new ClearUserPasswordEvent());
 
                                // Output faces message
                                this.showFacesMessage("form_register_page1:userPassword", "ERROR_USER_PASSWORD_EMPTY"); //NOI18N