[BUGFIX] Do not log out a logged out user 66/41466/3
authorHelmut Hummel <helmut.hummel@typo3.org>
Thu, 16 Jul 2015 12:48:20 +0000 (14:48 +0200)
committerAndreas Wolf <andreas.wolf@typo3.org>
Thu, 16 Jul 2015 18:27:11 +0000 (20:27 +0200)
It can happen that the logout action of the logout
controller is called without a user being logged in.

To avoid a fatal error, we do not call the logoff
code any more and just do the redirect handling.

Releases: master, 6.2
Resolves: #68220
Change-Id: I06f6289d01c681d4b412910ded8e9894f377892d
Reviewed-on: http://review.typo3.org/41466
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
typo3/sysext/backend/Classes/Controller/LogoutController.php

index d6be9c9..92f1ed9 100644 (file)
@@ -30,10 +30,12 @@ class LogoutController {
         * @return void
         */
        public function logout() {
-               // Logout written to log
-               $GLOBALS['BE_USER']->writelog(255, 2, 0, 1, 'User %s logged out from TYPO3 Backend', array($GLOBALS['BE_USER']->user['username']));
-               \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get()->removeSessionTokenFromRegistry();
-               $GLOBALS['BE_USER']->logoff();
+               if (!empty($GLOBALS['BE_USER']->user['username'])) {
+                       // Logout written to log
+                       $GLOBALS['BE_USER']->writelog(255, 2, 0, 1, 'User %s logged out from TYPO3 Backend', array($GLOBALS['BE_USER']->user['username']));
+                       \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get()->removeSessionTokenFromRegistry();
+                       $GLOBALS['BE_USER']->logoff();
+               }
                $redirect = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('redirect'));
                $redirectUrl = $redirect ? $redirect : 'index.php';
                \TYPO3\CMS\Core\Utility\HttpUtility::redirect($redirectUrl);