]>
Commit | Line | Data |
---|---|---|
8e47af2b A |
1 | <?php |
2 | ||
3 | declare(strict_types=1); | |
4 | ||
2899ebb5 | 5 | namespace Shaarli\Front\Controller\Admin; |
8e47af2b A |
6 | |
7 | use Shaarli\Security\LoginManager; | |
8 | use Slim\Http\Request; | |
9 | use 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. | |
8e47af2b | 16 | */ |
2899ebb5 | 17 | class LogoutController extends ShaarliAdminController |
8e47af2b A |
18 | { |
19 | public function index(Request $request, Response $response): Response | |
20 | { | |
21 | $this->container->pageCacheManager->invalidateCaches(); | |
22 | $this->container->sessionManager->logout(); | |
23 | ||
24 | // TODO: switch to a simple Cookie manager allowing to check the session, and create mocks. | |
9c75f877 | 25 | setcookie(LoginManager::$STAY_SIGNED_IN_COOKIE, 'false', 0, $this->container->basePath . '/'); |
8e47af2b | 26 | |
9c75f877 | 27 | return $this->redirect($response, '/'); |
8e47af2b A |
28 | } |
29 | } |