From: Roland Häder Date: Mon, 23 May 2016 12:53:02 +0000 (+0200) Subject: added pre-checks on user account X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=13700b795aa7597e6c3b8f1da353e8fca6840254;p=jjobs-war.git added pre-checks on user account Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java index e3c35700..071094c0 100644 --- a/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java @@ -17,9 +17,7 @@ package org.mxchange.jjobs.beans.resendlink; import java.text.MessageFormat; -import java.util.Locale; import javax.enterprise.context.SessionScoped; -import javax.faces.context.FacesContext; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; @@ -28,9 +26,13 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcoreee.utils.FacesUtils; import org.mxchange.jjobs.beans.BaseJobsController; +import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController; import org.mxchange.jjobs.beans.user.JobsUserWebSessionController; import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException; +import org.mxchange.jusercore.exceptions.UserStatusConfirmedException; +import org.mxchange.jusercore.exceptions.UserStatusLockedException; import org.mxchange.jusercore.model.user.User; +import org.mxchange.jusercore.model.user.status.UserAccountStatus; /** * A web session bean for resending confirmation link @@ -57,7 +59,13 @@ public class JobsResendLinkWebSessionBean extends BaseJobsController implements private ResendLinkSessionBeanRemote emailBean; /** - * User controller + * Localization controller + */ + @Inject + private JobsLocalizationSessionController localizationController; + + /** + * Regular user controller */ @Inject private JobsUserWebSessionController userController; @@ -98,14 +106,23 @@ public class JobsResendLinkWebSessionBean extends BaseJobsController implements throw new FaceletException(MessageFormat.format("this.emailAddress={0} should be resolveable into User instance.", this.getEmailAddress()), ex); //NOI18N } - // Get locale from faces context - Locale locale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale(); + // Is the user account already confirmed? + if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) { + // Then abort here + throw new FaceletException(new UserStatusConfirmedException(user)); + } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) { + // User account is locked + throw new FaceletException(new UserStatusLockedException(user)); + } else if (user.getUserConfirmKey() == null) { + // Status is UNCONFIRMED but confirmation key is NULL + throw new NullPointerException("user.userConfirmKey is null"); //NOI18N + } // Get base URL String baseUrl = FacesUtils.generateBaseUrl(); // Call EJB and return redirect target - this.emailBean.resendConfirmationLink(user, locale, baseUrl); + this.emailBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl); // Clear this bean this.clear();