]> git.mxchange.org Git - jjobs-war.git/commitdiff
fixed 2nd parameter, it can be easily generated within a JSF application
authorRoland Häder <roland@mxchange.org>
Wed, 18 May 2016 12:50:42 +0000 (14:50 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 26 May 2016 14:59:05 +0000 (16:59 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/email_address/JobsEmailChangeWebSessionBean.java
src/java/org/mxchange/jjobs/beans/register/JobsUserRegisterWebSessionBean.java
src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java
web/WEB-INF/templates/guest/guest_menu.tpl
web/guest/user/login.xhtml

index c30ee111de3c0c017f1b4e54497c83a4b168e1e0..81e4726938662bb7d74fe2368b47a9e957a95602 100644 (file)
@@ -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();
index 05b79d704c0dae25a724903672ceb9bc29579915..5b4f1797c798760868d37dd3fec280627d5da1ee 100644 (file)
@@ -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
index c394217a85f267243d035d9d6301aa9a53d096c3..900f200f61be04fb527df1e7d8913c10088ffbd5 100644 (file)
  */
 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
index 1830569927b975c9fed06a58f164676d3a1618a1..be83b4a19e751be777d41985c8d0368977050e43 100644 (file)
                                        <h:link title="#{msg.LINK_GUEST_REGISTER_TITLE}" outcome="user_register" value="#{msg.LINK_GUEST_REGISTER}" />
                                </li>
 
-<<<<<<< HEAD
-                               <li>
-                                       <h:link title="#{msg.LINK_GUEST_PASSWORD_TITLE}" outcome="user_lost_passwd" value="#{msg.LINK_GUEST_PASSWORD}" />
-                               </li>
-
-                               <li>
-                                       <h:link title="#{msg.LINK_GUEST_RESEND_LINK_TITLE}" outcome="user_resend_link" value="#{msg.LINK_GUEST_RESEND_LINK}" />
-                               </li>
-=======
                                <ui:fragment rendered="#{userController.isUserNameRequired()}">
                                        <li>
                                                <h:link title="#{msg.LINK_GUEST_PASSWORD_TITLE}" outcome="user_lost_passwd" value="#{msg.LINK_GUEST_PASSWORD}" />
@@ -56,7 +47,6 @@
                                                <h:link title="#{msg.LINK_GUEST_RESEND_LINK_TITLE}" outcome="user_resend_link" value="#{msg.LINK_GUEST_RESEND_LINK}" />
                                        </li>
                                </ui:fragment>
->>>>>>> 4a789c7... Rewritten a lot:
                        </ul>
                </div>
        </div>
index 8c7aa57dc9ba49f88df158c0cb587c73e100cde5..86d56b7ce06963cb0a7411e597d85278f894ef5f 100644 (file)
                </ui:define>
 
                <ui:define name="content">
-<<<<<<< HEAD
-                       <div class="para">
-                               <!-- TODO Internatialize this somehow //-->
-                               Noch kein Benutzerkonto? Einfach <h:link id="user_register" outcome="user_register" title="Als Benutzer anmelden">hier</h:link> anmelden.
-                       </div>
-
-                       <div class="para">
-                               <ui:include src="/WEB-INF/templates/guest/user/guest_login_form.tpl" />
-                       </div>
-
-                       <div class="para">
-                               <h:link id="user_lost_password" outcome="user_lost_passwd" title="#{msg.LINK_TITLE_GUEST_LOGIN_LOST_PASSWORD}" value="#{msg.LINK_GUEST_LOGIN_LOST_PASSWORD}" />
-                       </div>
-=======
                        <ui:fragment rendered="#{userController.isUserNameRequired()}">
                                <div class="para">
                                        <!-- TODO Internatialize this somehow //-->
@@ -48,7 +34,6 @@
                        <ui:fragment rendered="#{not userController.isUserNameRequired()}">
                                <h:outputText styleClass="errors" value="#{msg.ERROR_GUEST_USER_LOGIN_DEACTIVATED}" />
                        </ui:fragment>
->>>>>>> 4a789c7... Rewritten a lot:
                </ui:define>
        </ui:composition>
 </html>