From 3ccd4631a95f299fcb86325d0e1b0c6908fc0a25 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 18 May 2016 14:50:42 +0200 Subject: [PATCH] fixed 2nd parameter, it can be easily generated within a JSF application MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../JobsEmailChangeWebSessionBean.java | 8 +++- .../JobsUserRegisterWebSessionBean.java | 6 ++- .../JobsResendLinkWebSessionBean.java | 43 ++++++++++++++++++- web/WEB-INF/templates/guest/guest_menu.tpl | 10 ----- web/guest/user/login.xhtml | 15 ------- 5 files changed, 53 insertions(+), 29 deletions(-) diff --git a/src/java/org/mxchange/jjobs/beans/email_address/JobsEmailChangeWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/email_address/JobsEmailChangeWebSessionBean.java index c30ee111..81e47269 100644 --- a/src/java/org/mxchange/jjobs/beans/email_address/JobsEmailChangeWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/email_address/JobsEmailChangeWebSessionBean.java @@ -27,6 +27,7 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jcoreee.utils.FacesUtils; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController; import org.mxchange.jusercore.exceptions.UserPasswordMismatchException; @@ -88,7 +89,7 @@ public class JobsEmailChangeWebSessionBean extends BaseJobsController implements this.emailBean = (EmailChangeSessionBeanRemote) context.lookup("java:global/jjobs-ejb/email-change!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N // Init list - this.emailAddresses = this.emailBean.allQueuedAddressesAsList(); + this.emailAddresses = this.emailBean.allQueuedAddresses(); } catch (final NamingException e) { // Throw again throw new FaceletException(e); @@ -132,8 +133,11 @@ public class JobsEmailChangeWebSessionBean extends BaseJobsController implements // Create change object, to save EJB calls, the hash is not generated here ChangeableEmailAddress emailChange = new EmailAddressChange(user, this.getEmailAddress()); + // Get base URL + String baseUrl = FacesUtils.generateBaseUrl(); + // Call EJB - this.emailBean.enqueueEmailAddressForChange(emailChange); + this.emailBean.enqueueEmailAddressForChange(emailChange, baseUrl); // Unset all so the user is forced to re-enter it this.clear(); diff --git a/src/java/org/mxchange/jjobs/beans/register/JobsUserRegisterWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/register/JobsUserRegisterWebSessionBean.java index 05b79d70..5b4f1797 100644 --- a/src/java/org/mxchange/jjobs/beans/register/JobsUserRegisterWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/register/JobsUserRegisterWebSessionBean.java @@ -29,6 +29,7 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.UserContact; +import org.mxchange.jcoreee.utils.FacesUtils; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.contact.JobsContactWebSessionController; import org.mxchange.jjobs.beans.user.JobsAdminUserWebRequestController; @@ -151,8 +152,11 @@ public class JobsUserRegisterWebSessionBean extends BaseJobsController implement } try { + // Get base URL + String baseUrl = FacesUtils.generateBaseUrl(); + // Call bean - User registeredUser = this.registerBean.registerUser(user); + User registeredUser = this.registerBean.registerUser(user, baseUrl); // The id number should be set assert (registeredUser.getUserId() instanceof Long) : "registeredUser.userId is null after registerUser() was called."; //NOI18N diff --git a/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java index c394217a..900f200f 100644 --- a/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java @@ -16,13 +16,21 @@ */ 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; import javax.naming.Context; 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.user.JobsUserWebSessionController; +import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException; +import org.mxchange.jusercore.model.user.User; /** * A web session bean for resending confirmation link @@ -48,6 +56,12 @@ public class JobsResendLinkWebSessionBean extends BaseJobsController implements */ private ResendLinkSessionBeanRemote emailBean; + /** + * User controller + */ + @Inject + private JobsUserWebSessionController userController; + /** * Default constructor */ @@ -67,7 +81,34 @@ public class JobsResendLinkWebSessionBean extends BaseJobsController implements @Override public String doResendLink () { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + // The email address should not be empty as the JSF validates this + if (this.getEmailAddress() == null) { + // Throw NPE + throw new NullPointerException("this.emailAddress is null"); //NOI18N + } + + // Init user instance + User user; + + try { + // Is the email address really not used? + user = this.userController.lookupUserByEmailAddress(this.getEmailAddress()); + } catch (final UserEmailAddressNotFoundException ex) { + // Not found, should not happen as the registeredvalidator should find it + 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(); + + // Get base URL + String baseUrl = FacesUtils.generateBaseUrl(); + + // Call EJB and return redirect target + String redirectTarget = this.emailBean.resendConfirmationLink(user, locale, baseUrl); + + // Return redirect target + return redirectTarget; } @Override diff --git a/web/WEB-INF/templates/guest/guest_menu.tpl b/web/WEB-INF/templates/guest/guest_menu.tpl index 18305699..be83b4a1 100644 --- a/web/WEB-INF/templates/guest/guest_menu.tpl +++ b/web/WEB-INF/templates/guest/guest_menu.tpl @@ -36,15 +36,6 @@ -<<<<<<< HEAD -
  • - -
  • - -
  • - -
  • -=======
  • @@ -56,7 +47,6 @@
  • ->>>>>>> 4a789c7... Rewritten a lot: diff --git a/web/guest/user/login.xhtml b/web/guest/user/login.xhtml index 8c7aa57d..86d56b7c 100644 --- a/web/guest/user/login.xhtml +++ b/web/guest/user/login.xhtml @@ -16,20 +16,6 @@ -<<<<<<< HEAD -
    - - Noch kein Benutzerkonto? Einfach hier anmelden. -
    - -
    - -
    - -
    - -
    -=======
    @@ -48,7 +34,6 @@ ->>>>>>> 4a789c7... Rewritten a lot: -- 2.39.5