- 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>
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;
// 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);
}
@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();
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));
}
}
- @Override
- public String getBaseTemplatePathName () {
- return this.baseTemplatePathName;
- }
-
@Override
public void setBaseTemplatePathName (final String baseTemplatePathName) {
this.baseTemplatePathName = baseTemplatePathName;
this.loggedInUser = loggedInUser;
}
+ @Override
+ public String getBaseTemplatePathName () {
+ return this.baseTemplatePathName;
+ }
+
@Override
public boolean ifCurrentPasswordMatches () {
// The current password must be set and not empty
@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;
}
* <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);
/**
* Logout for administrator area. If a logged-in user instance exists, it is
xmlns:f="http://xmlns.jcp.org/jsf/core"
>
- <ui:composition template="/WEB-INF/templates/#{loginController.templateType}/#{loginController.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">
<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>
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">
</f:viewParam>
</f:metadata>
- <ui:composition template="/WEB-INF/templates/#{loginController.templateType}/#{loginController.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">
xmlns:f="http://xmlns.jcp.org/jsf/core"
>
- <ui:composition template="/WEB-INF/templates/#{loginController.templateType}/#{loginController.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">
xmlns:f="http://xmlns.jcp.org/jsf/core"
>
- <ui:composition template="/WEB-INF/templates/#{loginController.templateType}/#{loginController.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">
xmlns:f="http://xmlns.jcp.org/jsf/core"
>
- <ui:composition template="/WEB-INF/templates/#{loginController.templateType}/#{loginController.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">