From: Roland Haeder Date: Sat, 12 Mar 2016 18:40:17 +0000 (+0100) Subject: cleared email addresses after check and before usage so the user is forced to re... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2d89c75151216b9fc6eb39641682ec8cdc9bf4f3;p=jjobs-war.git cleared email addresses after check and before usage so the user is forced to re-enter them. --- diff --git a/src/java/org/mxchange/jjobs/beans/email_address/EmailChangeWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/email_address/EmailChangeWebSessionBean.java index b827d795..002416fe 100644 --- a/src/java/org/mxchange/jjobs/beans/email_address/EmailChangeWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/email_address/EmailChangeWebSessionBean.java @@ -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. + *

+ * @param emailAddress Email address to verify *

* @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