]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
added some checks for user name / email address, the user name may be optional
authorRoland Häder <roland@mxchange.org>
Fri, 13 May 2016 08:14:03 +0000 (10:14 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 13 May 2016 19:43:04 +0000 (21:43 +0200)
src/java/org/mxchange/pizzaapplication/beans/register/PizzaUserRegisterWebSessionBean.java

index df60314ea588843931866c85eff548ba455cc6dd..7334b8b96dde3bbfd5776e52a273aca0b9dc4b6f 100644 (file)
@@ -113,7 +113,7 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme
                } else if (!this.userController.isRequiredPersonalDataSet()) {
                        // Not all required fields are set
                        throw new FaceletException("Not all required fields are set."); //NOI18N
-               } else if (this.userController.isUserNameRegistered(user)) {
+               } 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())) {
@@ -162,6 +162,24 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme
 
        @Override
        public String doRegisterMultiPage1 () {
+               // Get user instance
+               User user = this.userController.createUserInstance();
+
+               // Page 1 has only email address and maybe user name
+               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
+               }
+
                // Now only redirect to next page as the JSF does it
                return "register_page2"; //NOI18N
        }