2020-01-23 21:52:03 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-05-22 13:20:31 +02:00
|
|
|
namespace Shaarli\Front\Controller\Admin;
|
2020-01-23 21:52:03 +01:00
|
|
|
|
2020-07-07 10:15:56 +02:00
|
|
|
use Shaarli\Security\CookieManager;
|
2020-01-23 21:52:03 +01:00
|
|
|
use Shaarli\Security\LoginManager;
|
|
|
|
use Slim\Http\Request;
|
|
|
|
use Slim\Http\Response;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class LogoutController
|
|
|
|
*
|
|
|
|
* Slim controller used to logout the user.
|
|
|
|
* It invalidates page cache and terminate the user session. Then it redirects to the homepage.
|
|
|
|
*/
|
2020-05-22 13:20:31 +02:00
|
|
|
class LogoutController extends ShaarliAdminController
|
2020-01-23 21:52:03 +01:00
|
|
|
{
|
|
|
|
public function index(Request $request, Response $response): Response
|
|
|
|
{
|
|
|
|
$this->container->pageCacheManager->invalidateCaches();
|
|
|
|
$this->container->sessionManager->logout();
|
2020-07-07 10:15:56 +02:00
|
|
|
$this->container->cookieManager->setCookieParameter(
|
|
|
|
CookieManager::STAY_SIGNED_IN,
|
|
|
|
'false',
|
|
|
|
0,
|
|
|
|
$this->container->basePath . '/'
|
|
|
|
);
|
2020-01-23 21:52:03 +01:00
|
|
|
|
2020-06-13 13:08:01 +02:00
|
|
|
return $this->redirect($response, '/');
|
2020-01-23 21:52:03 +01:00
|
|
|
}
|
|
|
|
}
|