]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Rewrites: (please cherry-pick also)
authorRoland Häder <roland@mxchange.org>
Fri, 10 Jun 2016 12:55:14 +0000 (14:55 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 27 Jul 2016 20:41:08 +0000 (22:41 +0200)
- rewrote templateType to baseTemplatePathName which allows more "complex" paths than just simple
- imprint, terms and privacy can now make usage of that new variable and don't need to be shown in new browser window

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java
src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionController.java
web/WEB-INF/templates.dist/guest_login_page.xhtml
web/WEB-INF/templates/login/user/user_footer.tpl
web/guest/user/user_list.xhtml
web/guest/user/user_profile.xhtml
web/imprint.xhtml
web/privacy.xhtml
web/terms.xhtml
web/user/login_logout.xhtml [new file with mode: 0644]

index 5f59aabd965ce575fafa588860f5fb547484611d..d11bf289d20fce99477b1df0738bb66f9a5a6592 100644 (file)
@@ -20,6 +20,7 @@ import java.util.Objects;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.event.Event;
 import javax.enterprise.inject.Any;
+import javax.faces.context.FacesContext;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -114,7 +115,10 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
                        Context context = new InitialContext();
 
                        // Try to lookup
-                       this.loginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/jrecruiter-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
+                       this.loginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
+
+                       // Defaul template is guest
+                       this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
                } catch (final NamingException ex) {
                        // Continue to throw
                        throw new FaceletException(ex);
@@ -122,7 +126,25 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
        }
 
        @Override
-       public String doLogin () {
+       public String doAdminLogout () {
+               // Is a user logged-in?
+               if (this.isUserLoggedIn()) {
+                       // Call other logout
+                       return this.doUserLogout();
+               }
+
+               // Invalidate session
+               FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
+
+               // Set template type to guest
+               this.setBaseTemplatePathName(GUEST_BASE_TEMPLATE_NAME); //NOI18N
+
+               // Redirect to index
+               return "index?faces-redirect=true"; //NOI18N
+       }
+
+       @Override
+       public String doUserLogin () {
                // Get user instance
                User user = this.userController.createUserLogin();
 
@@ -137,7 +159,7 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
                        this.setLoggedInUser(confirmedUser);
 
                        // Set template to "login"
-                       this.setTemplateType("login"); //NOI18N
+                       this.setBaseTemplatePathName(USER_BASE_TEMPLATE_NAME); //NOI18N
 
                        // Fire event away. Keep this last before return statement.
                        this.loginEvent.fire(new UserLoginEvent(confirmedUser));
@@ -150,11 +172,6 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
                }
        }
 
-       @Override
-       public String getBaseTemplatePathName () {
-               return this.baseTemplatePathName;
-       }
-
        @Override
        public void setBaseTemplatePathName (final String baseTemplatePathName) {
                this.baseTemplatePathName = baseTemplatePathName;
@@ -180,6 +197,11 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
                this.loggedInUser = loggedInUser;
        }
 
+       @Override
+       public String getBaseTemplatePathName () {
+               return this.baseTemplatePathName;
+       }
+
        @Override
        public boolean ifCurrentPasswordMatches () {
                // The current password must be set and not empty
@@ -217,15 +239,9 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
 
        @Override
        public boolean isUserLoggedIn () {
-               // Trace message
-               // NOISY-DEBUG System.out.println(MessageFormat.format("RecruiterUserLoginWebSessionBean:isUserLoggedIn: this.loggedInUser={0},this.templateType={1} - CALLED!", this.getLoggedInUser(), this.getTemplateType()));
-
                // Compare instance
                this.userLoggedIn = ((this.getLoggedInUser() instanceof User) && (Objects.equals(this.getLoggedInUser().getUserAccountStatus(), UserAccountStatus.CONFIRMED)));
 
-               // Trace message
-               // NOISY-DEBUG System.out.println(MessageFormat.format("RecruiterUserLoginWebSessionBean:isUserLoggedIn: this.userLoggedIn={0} - EXIT!", this.userLoggedIn));
-
                // Return it
                return this.userLoggedIn;
        }
index c8ec08aca5601da19f20f0a6ff56cba528998849..f7ff64159853dc677d960c7e5860b85766aaada1 100644 (file)
@@ -31,14 +31,14 @@ public interface PizzaUserLoginWebSessionController extends Serializable {
         * <p>
         * @return Template type
         */
-       String getTemplateType ();
+       String getBaseTemplatePathName ();
 
        /**
         * Setter for template type
         * <p>
-        * @param templateType Template type
+        * @param baseTemplatePathName Template type
         */
-       void setTemplateType (final String templateType);
+       void setBaseTemplatePathName (final String baseTemplatePathName);
 
        /**
         * Logins the user, if the account is found, confirmed and unlocked.
index 4c614aa545389786b1b59137f80a9e031338b267..eb4dd3280e9a17489b8d1a1f64701ccbad24669e 100644 (file)
@@ -7,7 +7,7 @@
        xmlns:f="http://xmlns.jcp.org/jsf/core"
        >
 
-       <ui:composition template="/WEB-INF/templates/#{userLoginController.templateType}/#{userLoginController.templateType}_base.tpl">
+       <ui:composition template="/WEB-INF/templates/#{userLoginController.baseTemplatePathName}_base.tpl">
                <ui:define name="guest_title">#{msg.PAGE_TITLE_INDEX_FOO}</ui:define>
 
                <ui:define name="content_header">
index bafe6e1bcdd62a1a5da388250ba88e3e8a9693e8..73d6d5e72cecdec96ba2a420f18a05b69068316b 100644 (file)
                                <h:link outcome="login_index" title="#{msg.LINK_LOGIN_HOME_TITLE}" value="#{msg.LINK_LOGIN_HOME}" />
                        </li>
 
-                       <li class="footer_link">
-                               <h:link outcome="imprint" title="#{msg.LINK_GUEST_IMPRINT_TITLE}" value="#{msg.LINK_GUEST_IMPRINT}" />
-                       </li>
+                       <ui:fragment rendered="#{featureController.isFeatureEnabled('imprint')}">
+                               <li class="footer_link">
+                                       <h:link outcome="imprint" title="#{msg.LINK_GUEST_IMPRINT_TITLE}" value="#{msg.LINK_GUEST_IMPRINT}" />
+                               </li>
+                       </ui:fragment>
 
-                       <li class="footer_link">
-                               <h:link outcome="terms" title="#{msg.LINK_GUEST_TERMS_TITLE}" value="#{msg.LINK_GUEST_TERMS}" />
-                       </li>
+                       <ui:fragment rendered="#{featureController.isFeatureEnabled('terms')}">
+                               <li class="footer_link">
+                                       <h:link outcome="terms" title="#{msg.LINK_GUEST_TERMS_TITLE}" value="#{msg.LINK_GUEST_TERMS}" />
+                               </li>
+                       </ui:fragment>
 
-                       <li class="footer_link">
-                               <h:link outcome="privacy" title="#{msg.LINK_GUEST_PRIVACY_TITLE}" value="#{msg.LINK_GUEST_PRIVACY}" />
-                       </li>
+                       <ui:fragment rendered="#{featureController.isFeatureEnabled('privacy')}">
+                               <li class="footer_link">
+                                       <h:link outcome="privacy" title="#{msg.LINK_GUEST_PRIVACY_TITLE}" value="#{msg.LINK_GUEST_PRIVACY}" />
+                               </li>
+                       </ui:fragment>
 
                        <li class="footer_copyright">Copyright (c) 2016 by Roland Häder</li>
                </ul>
index 031f3b69f18c5770114ac0c2f5ed67682715102c..5284b2c430b37d404247106c63eb883c1254f438 100644 (file)
@@ -6,7 +6,7 @@
          xmlns:h="http://xmlns.jcp.org/jsf/html"
          xmlns:f="http://xmlns.jcp.org/jsf/core">
 
-       <ui:composition template="/WEB-INF/templates/#{userLoginController.templateType}/#{userLoginController.templateType}_base.tpl">
+       <ui:composition template="/WEB-INF/templates/#{userLoginController.baseTemplatePathName}_base.tpl">
                <ui:define name="login_title">#{msg.PAGE_TITLE_USER_LIST}</ui:define>
 
                <ui:define name="content_header">
index 89a917f5d50f9d0e2690714aacf676c3d9d58f35..280d0c9c52f88906abb2ecf3a1dc822316252f0c 100644 (file)
@@ -13,8 +13,8 @@
                </f:viewParam>
        </f:metadata>
 
-       <ui:composition template="/WEB-INF/templates/#{userLoginController.templateType}/#{userLoginController.templateType}_base.tpl">
-               <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_USER_PROFILE}</ui:define>
+       <ui:composition template="/WEB-INF/templates/#{userLoginController.baseTemplatePathName}_base.tpl">
+               <ui:define name="login_title">#{msg.PAGE_TITLE_USER_LOGIN_USER_PROFILE}</ui:define>
                <ui:define name="guest_title">#{msg.PAGE_TITLE_INDEX_USER_PROFILE}</ui:define>
 
                <ui:define name="content_header">
index 8965e3f6d2e42d8ad2af74fa8bc728ea8c72db36..f3f6ca38156f64b4b9eaea71444aaaa6ac780a5e 100644 (file)
@@ -7,7 +7,7 @@
        xmlns:f="http://xmlns.jcp.org/jsf/core"
        >
 
-       <ui:composition template="/WEB-INF/templates/#{userLoginController.templateType}/#{userLoginController.templateType}_base.tpl">
+       <ui:composition template="/WEB-INF/templates/#{userLoginController.baseTemplatePathName}_base.tpl">
                <ui:define name="guest_title">#{msg.PAGE_TITLE_INDEX_IMPRINT}</ui:define>
 
                <ui:define name="content_header">
index b50e729cdfc09ec68917bca059484813f33a242b..805f59849a44d7fa5a2e03719611e0924e9d7c1f 100644 (file)
@@ -7,7 +7,7 @@
        xmlns:f="http://xmlns.jcp.org/jsf/core"
        >
 
-       <ui:composition template="/WEB-INF/templates/#{userLoginController.templateType}/#{userLoginController.templateType}_base.tpl">
+       <ui:composition template="/WEB-INF/templates/#{userLoginController.baseTemplatePathName}_base.tpl">
                <ui:define name="guest_title">#{msg.PAGE_TITLE_INDEX_PRIVACY}</ui:define>
 
                <ui:define name="content_header">
index e8270e846e7be6f03786fca9909b88100dbc118c..2b34613f1b81016980bf5ad150c065ee12db037f 100644 (file)
@@ -7,7 +7,7 @@
        xmlns:f="http://xmlns.jcp.org/jsf/core"
        >
 
-       <ui:composition template="/WEB-INF/templates/#{userLoginController.templateType}/#{userLoginController.templateType}_base.tpl">
+       <ui:composition template="/WEB-INF/templates/#{userLoginController.baseTemplatePathName}_base.tpl">
                <ui:define name="guest_title">#{msg.PAGE_TITLE_INDEX_TERMS}</ui:define>
 
                <ui:define name="content_header">
diff --git a/web/user/login_logout.xhtml b/web/user/login_logout.xhtml
new file mode 100644 (file)
index 0000000..2702221
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
+       lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
+       xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+       xmlns:h="http://xmlns.jcp.org/jsf/html"
+       xmlns:f="http://xmlns.jcp.org/jsf/core"
+       >
+
+       <ui:composition template="/WEB-INF/templates/login/user/user_base.tpl">
+               <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_USER_LOGOUT}</ui:define>
+
+               <ui:define name="content_header">
+                       #{msg.CONTENT_TITLE_LOGIN_USER_LOGOUT}
+               </ui:define>
+
+               <ui:define name="content">
+                       <h:form id="user_logout">
+                               <div class="table">
+                                       <div class="table_header">
+                                               <h:outputText value="#{msg.LOGIN_USER_LOGOUT_TITLE}" />
+                                       </div>
+
+                                       <div class="para">
+                                               <h:outputText value="#{msg.LOGIN_USER_LOGOUT_NOTICE}" />
+                                       </div>
+
+                                       <div class="table_footer">
+                                               <h:commandButton styleClass="reset" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
+                                               <h:commandButton styleClass="submit" type="submit" action="#{userLoginController.doUserLogout()}" value="#{msg.BUTTON_USER_LOGOUT}" />
+                                       </div>
+                               </div>
+                       </h:form>
+               </ui:define>
+       </ui:composition>
+</html>