processLogout(); $redirectUrl = $request->getParsedBody()['redirect'] ?? $request->getQueryParams()['redirect']; $redirectUrl = GeneralUtility::sanitizeLocalUrl($redirectUrl); if (empty($redirectUrl)) { $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $redirectUrl = (string)$uriBuilder->buildUriFromRoute('login', [], $uriBuilder::ABSOLUTE_URL); } return new RedirectResponse(GeneralUtility::locationHeaderUrl($redirectUrl), 303); } /** * Performs the logout processing * * @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0 */ public function logout() { trigger_error('LogoutController->logout() will be replaced by protected method processLogout() in TYPO3 v10.0. Do not call from other extension.', E_USER_DEPRECATED); $this->processLogout(); } /** * Performs the logout processing */ protected function processLogout(): void { if (empty($this->getBackendUser()->user['username'])) { return; } // Logout written to log $this->getBackendUser()->writelog(255, 2, 0, 1, 'User %s logged out from TYPO3 Backend', [$this->getBackendUser()->user['username']]); /** @var \TYPO3\CMS\Core\FormProtection\BackendFormProtection $backendFormProtection */ $backendFormProtection = FormProtectionFactory::get(); $backendFormProtection->removeSessionTokenFromRegistry(); $this->getBackendUser()->logoff(); } /** * Returns the current BE user. * * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */ protected function getBackendUser() { return $GLOBALS['BE_USER']; } }