]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Fix for multi-page registration:
authorRoland Häder <roland@mxchange.org>
Fri, 13 May 2016 08:36:02 +0000 (10:36 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 13 May 2016 20:34:36 +0000 (22:34 +0200)
- a contact instance is needed to check for email address as it is stored there
- so first create a "half" contact instance (no gender, ...) and then check email address
- user name can be only checked, if required

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/addressbook/beans/register/AddressbookUserRegisterWebSessionBean.java

index 638954b27da7d687915e80c0037e41ec2ea993dd..f68c05324b81f278ed22fb27d52526155efcdc30 100644 (file)
@@ -31,6 +31,8 @@ import org.mxchange.addressbook.beans.BaseAddressbookController;
 import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController;
 import org.mxchange.addressbook.beans.user.AddressbookAdminUserWebRequestController;
 import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.UserContact;
 import org.mxchange.jusercore.events.registration.RegisteredUserEvent;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
 import org.mxchange.jusercore.exceptions.DataRepeatMismatchException;
@@ -165,21 +167,31 @@ public class AddressbookUserRegisterWebSessionBean extends BaseAddressbookContro
                // Get user instance
                User user = this.userController.createUserInstance();
 
-               // Page 1 has only email address and maybe user name
+               // First check if user is not null and user name is not used + if same email address is entered
                if (null == user) {
                        // user must be set
                        throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N
                } else if ((this.userController.isUserNameRequired()) && (this.userController.isUserNameRegistered(user))) {
                        // User name is already used
                        throw new FaceletException(new UserNameAlreadyRegisteredException(user));
-               } else if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
-                       // Email address has already been taken
-                       throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
                } else if (!this.contactController.isSameEmailAddressEntered()) {
                        // Not same email address entered
                        throw new FaceletException(new DataRepeatMismatchException(MessageFormat.format("Email addresses not matching: {0} != {1}", this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat()))); //NOI18N
                }
 
+               // Create half contact instance with email address
+               Contact contact = new UserContact();
+               contact.setContactEmailAddress(this.contactController.getEmailAddress());
+
+               // Set contact in user
+               user.setUserContact(contact);
+
+               // Check if email address is registered
+               if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
+                       // Email address has already been taken
+                       throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
+               }
+
                // Now only redirect to next page as the JSF does it
                return "register_page2"; //NOI18N
        }