2022-09-13 13:14:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
2023-08-03 01:35:08 +00:00
|
|
|
use Misuzu\Auth\AuthTokenCookie;
|
|
|
|
|
2023-09-06 20:06:07 +00:00
|
|
|
$authInfo = $msz->getAuthInfo();
|
|
|
|
if($authInfo->isLoggedIn()) {
|
2023-08-03 01:35:08 +00:00
|
|
|
if(!CSRF::validateRequest()) {
|
|
|
|
Template::render('auth.logout');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-09-06 20:06:07 +00:00
|
|
|
$tokenInfo = $authInfo->getTokenInfo();
|
2023-08-03 01:35:08 +00:00
|
|
|
|
2023-09-08 00:43:00 +00:00
|
|
|
$authCtx = $msz->getAuthContext();
|
|
|
|
$authCtx->getSessions()->deleteSessions(sessionTokens: $tokenInfo->getSessionToken());
|
2023-08-03 01:35:08 +00:00
|
|
|
|
|
|
|
$tokenBuilder = $tokenInfo->toBuilder();
|
|
|
|
$tokenBuilder->removeUserId();
|
|
|
|
$tokenBuilder->removeSessionToken();
|
|
|
|
$tokenBuilder->removeImpersonatedUserId();
|
|
|
|
$tokenInfo = $tokenBuilder->toInfo();
|
2022-09-13 13:14:49 +00:00
|
|
|
|
2023-08-03 01:35:08 +00:00
|
|
|
AuthTokenCookie::apply($tokenPacker->pack($tokenInfo));
|
2022-09-13 13:14:49 +00:00
|
|
|
}
|
|
|
|
|
2023-09-08 20:40:48 +00:00
|
|
|
Tools::redirect($msz->getURLs()->format('index'));;
|