From 12796bcb81adbebef5d3eb85254fe5b3726ce0b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 13 May 2016 10:14:03 +0200 Subject: [PATCH] added some checks for user name / email address, the user name may be optional --- .../JobsUserRegisterWebSessionBean.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/java/org/mxchange/jjobs/beans/register/JobsUserRegisterWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/register/JobsUserRegisterWebSessionBean.java index bb715862..d37f2aac 100644 --- a/src/java/org/mxchange/jjobs/beans/register/JobsUserRegisterWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/register/JobsUserRegisterWebSessionBean.java @@ -113,7 +113,7 @@ public class JobsUserRegisterWebSessionBean extends BaseJobsController implement } 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 JobsUserRegisterWebSessionBean extends BaseJobsController implement @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 } -- 2.39.5