From e96ce2fccdafc837a4bcc2d6c5c8235be1b7bf7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 10 Jun 2016 14:55:14 +0200 Subject: [PATCH] Rewrites: (please cherry-pick also) - 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../login/PizzaUserLoginWebSessionBean.java | 44 +++++++++++++------ .../PizzaUserLoginWebSessionController.java | 6 +-- .../templates.dist/guest_login_page.xhtml | 2 +- .../templates/login/user/user_footer.tpl | 24 ++++++---- web/guest/user/user_list.xhtml | 2 +- web/guest/user/user_profile.xhtml | 4 +- web/imprint.xhtml | 2 +- web/privacy.xhtml | 2 +- web/terms.xhtml | 2 +- web/user/login_logout.xhtml | 36 +++++++++++++++ 10 files changed, 91 insertions(+), 33 deletions(-) create mode 100644 web/user/login_logout.xhtml diff --git a/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java index 5f59aabd..d11bf289 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java @@ -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; } diff --git a/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionController.java index c8ec08ac..f7ff6415 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionController.java @@ -31,14 +31,14 @@ public interface PizzaUserLoginWebSessionController extends Serializable { *

* @return Template type */ - String getTemplateType (); + String getBaseTemplatePathName (); /** * Setter for template type *

- * @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. diff --git a/web/WEB-INF/templates.dist/guest_login_page.xhtml b/web/WEB-INF/templates.dist/guest_login_page.xhtml index 4c614aa5..eb4dd328 100644 --- a/web/WEB-INF/templates.dist/guest_login_page.xhtml +++ b/web/WEB-INF/templates.dist/guest_login_page.xhtml @@ -7,7 +7,7 @@ xmlns:f="http://xmlns.jcp.org/jsf/core" > - + #{msg.PAGE_TITLE_INDEX_FOO} diff --git a/web/WEB-INF/templates/login/user/user_footer.tpl b/web/WEB-INF/templates/login/user/user_footer.tpl index bafe6e1b..73d6d5e7 100644 --- a/web/WEB-INF/templates/login/user/user_footer.tpl +++ b/web/WEB-INF/templates/login/user/user_footer.tpl @@ -10,17 +10,23 @@ -

+ + + - + + + - + + + diff --git a/web/guest/user/user_list.xhtml b/web/guest/user/user_list.xhtml index 031f3b69..5284b2c4 100644 --- a/web/guest/user/user_list.xhtml +++ b/web/guest/user/user_list.xhtml @@ -6,7 +6,7 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core"> - + #{msg.PAGE_TITLE_USER_LIST} diff --git a/web/guest/user/user_profile.xhtml b/web/guest/user/user_profile.xhtml index 89a917f5..280d0c9c 100644 --- a/web/guest/user/user_profile.xhtml +++ b/web/guest/user/user_profile.xhtml @@ -13,8 +13,8 @@ - - #{msg.PAGE_TITLE_LOGIN_USER_PROFILE} + + #{msg.PAGE_TITLE_USER_LOGIN_USER_PROFILE} #{msg.PAGE_TITLE_INDEX_USER_PROFILE} diff --git a/web/imprint.xhtml b/web/imprint.xhtml index 8965e3f6..f3f6ca38 100644 --- a/web/imprint.xhtml +++ b/web/imprint.xhtml @@ -7,7 +7,7 @@ xmlns:f="http://xmlns.jcp.org/jsf/core" > - + #{msg.PAGE_TITLE_INDEX_IMPRINT} diff --git a/web/privacy.xhtml b/web/privacy.xhtml index b50e729c..805f5984 100644 --- a/web/privacy.xhtml +++ b/web/privacy.xhtml @@ -7,7 +7,7 @@ xmlns:f="http://xmlns.jcp.org/jsf/core" > - + #{msg.PAGE_TITLE_INDEX_PRIVACY} diff --git a/web/terms.xhtml b/web/terms.xhtml index e8270e84..2b34613f 100644 --- a/web/terms.xhtml +++ b/web/terms.xhtml @@ -7,7 +7,7 @@ xmlns:f="http://xmlns.jcp.org/jsf/core" > - + #{msg.PAGE_TITLE_INDEX_TERMS} diff --git a/web/user/login_logout.xhtml b/web/user/login_logout.xhtml new file mode 100644 index 00000000..27022217 --- /dev/null +++ b/web/user/login_logout.xhtml @@ -0,0 +1,36 @@ + + + + + #{msg.PAGE_TITLE_LOGIN_USER_LOGOUT} + + + #{msg.CONTENT_TITLE_LOGIN_USER_LOGOUT} + + + + +
+
+ +
+ +
+ +
+ + +
+
+
+
+ -- 2.39.5