]> git.mxchange.org Git - jjobs-war.git/commitdiff
re-added doUserLogout() + removed doLogout() as it was to generic
authorRoland Haeder <roland@mxchange.org>
Thu, 28 Jul 2016 20:06:29 +0000 (22:06 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 7 Aug 2016 12:09:57 +0000 (14:09 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/login/JobsUserLoginWebSessionBean.java

index 473f2db5279efad23d1d369970b64e74d2a6b569..9bf9bb7cc6da0513b64e2f1b0c20bce23367a4b9 100644 (file)
@@ -38,6 +38,7 @@ import org.mxchange.jusercore.container.login.UserLoginContainer;
 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.events.login.UserLoginEvent;
 import org.mxchange.jusercore.events.logout.ObserveableUserLogoutEvent;
+import org.mxchange.jusercore.events.logout.UserLogoutEvent;
 import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
@@ -239,6 +240,34 @@ public class JobsUserLoginWebSessionBean extends BaseJobsController implements J
                }
        }
 
+       @Override
+       public String doUserLogout () {
+               // Is loggedInUser set?
+               if (this.getLoggedInUser() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.loggedInUser is null"); //NOI18N
+               } else if (this.getLoggedInUser().getUserId() == null) {
+                       // Throw again
+                       throw new NullPointerException("this.loggedInUser.userId is null"); //NOI18N
+               } else if (this.getLoggedInUser().getUserId() < 1) {
+                       // Invalid user id
+                       throw new IllegalStateException(MessageFormat.format("this.loggedInUser.userId={0} is not valid.", this.getLoggedInUser().getUserId())); //NOI18N
+               }
+
+               // Fire event
+               this.userLogoutEvent.fire(new UserLogoutEvent(this.getLoggedInUser()));
+
+               // Invalidate session
+               FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
+
+               // Unset any user instances
+               this.setLoggedInUser(null);
+               this.setBaseTemplatePathName(GUEST_BASE_TEMPLATE_NAME); //NOI18N
+
+               // Redirect to index
+               return "index"; //NOI18N
+       }
+
        @Override
        public String getBaseTemplatePathName () {
                return this.baseTemplatePathName;