]> git.mxchange.org Git - jjobs-war.git/commitdiff
cleared email addresses after check and before usage so the user is forced to re...
authorRoland Haeder <roland@mxchange.org>
Sat, 12 Mar 2016 18:40:17 +0000 (19:40 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 12 Mar 2016 18:40:17 +0000 (19:40 +0100)
src/java/org/mxchange/jjobs/beans/email_address/EmailChangeWebSessionBean.java

index b827d795aec6cab6524e760aca28c0668ba9b387..002416fe260c34284354260d13d0eaf2a2fb0edc 100644 (file)
@@ -123,14 +123,20 @@ public class EmailChangeWebSessionBean implements EmailChangeWebSessionControlle
                assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
                assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
 
+               // Get dummy email address
+               String dummyEmail = this.getEmailAddress1();
+
+               // Unset all so the user is forced to re-enter it
+               this.clear();
+
                // Check if the email address is already enqueued
-               if (this.isEmailAddressQueued()) {
+               if (this.isEmailAddressQueued(dummyEmail)) {
                        // Yes, then abort here
                        return "login_email_already_added"; //NOI18N
                }
 
                // Create change object, to save EJB calls, the hash is not generated here
-               ChangeableEmailAddress emailAddress = new EmailAddressChange(user, this.getEmailAddress1(), new GregorianCalendar());
+               ChangeableEmailAddress emailAddress = new EmailAddressChange(user, dummyEmail, new GregorianCalendar());
 
                // Call EJB
                this.emailBean.enqueueEmailAddressForChange(emailAddress);
@@ -166,30 +172,41 @@ public class EmailChangeWebSessionBean implements EmailChangeWebSessionControlle
        }
 
        /**
-        * Checks if current emailAddress1 has already been queued. First a local
-        * list is being checked, if not found, the EJB is called. Only if found,
-        * the result is "cached" in the list.
+        * Clears email address fields so the user has to re-enter them
+        */
+       private void clear () {
+               // Clear fields
+               this.setEmailAddress1(null);
+               this.setEmailAddress2(null);
+       }
+
+       /**
+        * Checks if given email address has already been queued. First a local list
+        * is being checked, if not found, the EJB is called. Only if found, the
+        * result is "cached" in the list.
+        * <p>
+        * @param emailAddress Email address to verify
         * <p>
         * @return Whether the email address in field emailAddress1 is already queued
         */
-       private boolean isEmailAddressQueued () {
+       private boolean isEmailAddressQueued (final String emailAddress) {
                // It should be there
-               assert (this.getEmailAddress1() != null) : "emailAddress1 should not be null"; //NOI18N
-               assert (!this.getEmailAddress1().trim().isEmpty()) : "emailAddress1 should not be empty"; //NOI18N
+               assert (emailAddress != null) : "emailAddress should not be null"; //NOI18N
+               assert (!emailAddress.trim().isEmpty()) : "emailAddress should not be empty"; //NOI18N
 
                // Check list
-               if (this.emailAddresses.contains(this.getEmailAddress1())) {
+               if (this.emailAddresses.contains(emailAddress)) {
                        // Okay, found it
                        return true;
                }
 
                // Check EJB
-               boolean isQueued = this.emailBean.isEmailAddressEnqueued(this.getEmailAddress1());
+               boolean isQueued = this.emailBean.isEmailAddressEnqueued(emailAddress);
 
                // Is it there?
                if (isQueued) {
                        // Add to list
-                       this.emailAddresses.add(this.getEmailAddress1());
+                       this.emailAddresses.add(emailAddress);
                }
 
                // Return status