Force logout of banned users
authorAlexander Ebert <ebert@woltlab.com>
Fri, 9 Jun 2017 08:04:23 +0000 (10:04 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 9 Jun 2017 08:04:23 +0000 (10:04 +0200)
wcfsetup/install/files/lib/system/WCF.class.php

index 0eaf4a380093186b7117359c47e6fe35bedd2a8c..915c7aced69b743a1dceef3c5f5f7704c5614dfe 100644 (file)
@@ -134,6 +134,12 @@ class WCF {
         */
        protected static $zendOpcacheEnabled = null;
        
+       /**
+        * force logout during destructor call
+        * @var boolean
+        */
+       protected static $forceLogout = false;
+       
        /**
         * Calls all init functions of the WCF class.
         */
@@ -181,7 +187,13 @@ class WCF {
                        
                        // update session
                        if (is_object(self::getSession())) {
-                               self::getSession()->update();
+                               if (self::$forceLogout) {
+                                       // do logout
+                                       WCF::getSession()->delete();
+                               }
+                               else {
+                                       self::getSession()->update();
+                               }
                        }
                        
                        // execute shutdown actions of user storage handler
@@ -445,6 +457,16 @@ class WCF {
                                throw new AJAXException(self::getLanguage()->getDynamicVariable('wcf.user.error.isBanned'), AJAXException::INSUFFICIENT_PERMISSIONS);
                        }
                        else {
+                               self::$forceLogout = true;
+                               
+                               // remove cookies
+                               if (isset($_COOKIE[COOKIE_PREFIX.'userID'])) {
+                                       HeaderUtil::setCookie('userID', 0);
+                               }
+                               if (isset($_COOKIE[COOKIE_PREFIX.'password'])) {
+                                       HeaderUtil::setCookie('password', '');
+                               }
+                               
                                throw new NamedUserException(self::getLanguage()->getDynamicVariable('wcf.user.error.isBanned'));
                        }
                }