]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - application/front/controllers/LogoutController.php
Process logout through Slim controller
[github/shaarli/Shaarli.git] / application / front / controllers / LogoutController.php
CommitLineData
8e47af2b
A
1<?php
2
3declare(strict_types=1);
4
5namespace Shaarli\Front\Controller;
6
7use Shaarli\Security\LoginManager;
8use Slim\Http\Request;
9use Slim\Http\Response;
10
11/**
12 * Class LogoutController
13 *
14 * Slim controller used to logout the user.
15 * It invalidates page cache and terminate the user session. Then it redirects to the homepage.
16 *
17 * @package Front\Controller
18 */
19class LogoutController extends ShaarliController
20{
21 public function index(Request $request, Response $response): Response
22 {
23 $this->container->pageCacheManager->invalidateCaches();
24 $this->container->sessionManager->logout();
25
26 // TODO: switch to a simple Cookie manager allowing to check the session, and create mocks.
27 setcookie(LoginManager::$STAY_SIGNED_IN_COOKIE, 'false', 0, $this->container->webPath);
28
29 return $response->withRedirect('./');
30 }
31}