From: Roland Häder Date: Fri, 10 Jun 2016 12:55:14 +0000 (+0200) Subject: Rewrites: (please cherry-pick also) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7470a9f1dc8bb5b13b3c8eb859fbe6d7516642ab;p=jfinancials-war.git 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 Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java index 8a6b8e19..ef7f22a2 100644 --- a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.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; @@ -130,6 +131,9 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle // Try to lookup this.loginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/addressbook-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); @@ -137,7 +141,25 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle } @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(); @@ -152,7 +174,7 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle 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.userLoginEvent.fire(new UserLoginEvent(confirmedUser)); @@ -168,11 +190,6 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle } } - @Override - public String getBaseTemplatePathName () { - return this.baseTemplatePathName; - } - @Override public void setBaseTemplatePathName (final String baseTemplatePathName) { this.baseTemplatePathName = baseTemplatePathName; @@ -198,6 +215,11 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle this.loggedInUser = loggedInUser; } + @Override + public String getBaseTemplatePathName () { + return this.baseTemplatePathName; + } + @Override public boolean ifCurrentPasswordMatches () { // The current password must be set and not empty @@ -235,15 +257,8 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle @Override public boolean isUserLoggedIn () { - // Trace message - // NOISY: System.out.println(MessageFormat.format("AddressbookUserLoginWebSessionBean: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: System.out.println(MessageFormat.format("AddressbookUserLoginWebSessionBean:isUserLoggedIn: this.userLoggedIn={0} - EXIT!", this.userLoggedIn)); - // Return it return this.userLoggedIn; } diff --git a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java index 63d2aa83..f5ee4f8b 100644 --- a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java +++ b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java @@ -31,14 +31,14 @@ public interface AddressbookUserLoginWebSessionController 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); /** * Logout for administrator area. If a logged-in user instance exists, it is diff --git a/web/WEB-INF/templates.dist/guest_login_page.xhtml b/web/WEB-INF/templates.dist/guest_login_page.xhtml index ff917af4..51239492 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 6c98bdc7..618584e0 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 059a23d9..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 b4961606..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 1f167519..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 e77faed4..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}