]>
Commit | Line | Data |
---|---|---|
8e47af2b A |
1 | <?php |
2 | ||
3 | declare(strict_types=1); | |
4 | ||
2899ebb5 | 5 | namespace Shaarli\Front\Controller\Admin; |
8e47af2b | 6 | |
c4ad3d4f | 7 | use Shaarli\Security\CookieManager; |
8e47af2b A |
8 | use Shaarli\Security\LoginManager; |
9 | use Slim\Http\Request; | |
10 | use Slim\Http\Response; | |
11 | ||
12 | /** | |
13 | * Class LogoutController | |
14 | * | |
15 | * Slim controller used to logout the user. | |
16 | * It invalidates page cache and terminate the user session. Then it redirects to the homepage. | |
8e47af2b | 17 | */ |
2899ebb5 | 18 | class LogoutController extends ShaarliAdminController |
8e47af2b A |
19 | { |
20 | public function index(Request $request, Response $response): Response | |
21 | { | |
22 | $this->container->pageCacheManager->invalidateCaches(); | |
23 | $this->container->sessionManager->logout(); | |
c4ad3d4f A |
24 | $this->container->cookieManager->setCookieParameter( |
25 | CookieManager::STAY_SIGNED_IN, | |
26 | 'false', | |
27 | 0, | |
28 | $this->container->basePath . '/' | |
29 | ); | |
8e47af2b | 30 | |
9c75f877 | 31 | return $this->redirect($response, '/'); |
8e47af2b A |
32 | } |
33 | } |