diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-01-23 21:52:03 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-07-23 21:19:21 +0200 |
commit | 8e47af2b3620c920116ec056173277c039163ec1 (patch) | |
tree | d77f31f17bf4485f5a3ec0fea895205e9bde0554 /application/front | |
parent | b0428aa9b02b058b72c40b6e8dc2298d55bf692f (diff) | |
download | Shaarli-8e47af2b3620c920116ec056173277c039163ec1.tar.gz Shaarli-8e47af2b3620c920116ec056173277c039163ec1.tar.zst Shaarli-8e47af2b3620c920116ec056173277c039163ec1.zip |
Process logout through Slim controller
Diffstat (limited to 'application/front')
-rw-r--r-- | application/front/controllers/LogoutController.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/application/front/controllers/LogoutController.php b/application/front/controllers/LogoutController.php new file mode 100644 index 00000000..aba078c3 --- /dev/null +++ b/application/front/controllers/LogoutController.php | |||
@@ -0,0 +1,31 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Shaarli\Front\Controller; | ||
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. | ||
16 | * | ||
17 | * @package Front\Controller | ||
18 | */ | ||
19 | class 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 | } | ||