misuzu/public-legacy/auth/logout.php

28 lines
723 B
PHP
Raw Permalink Normal View History

2022-09-13 13:14:49 +00:00
<?php
namespace Misuzu;
use Misuzu\Auth\AuthTokenCookie;
$authInfo = $msz->getAuthInfo();
if($authInfo->isLoggedIn()) {
if(!CSRF::validateRequest()) {
Template::render('auth.logout');
return;
}
$tokenInfo = $authInfo->getTokenInfo();
2023-09-08 00:43:00 +00:00
$authCtx = $msz->getAuthContext();
$authCtx->getSessions()->deleteSessions(sessionTokens: $tokenInfo->getSessionToken());
$tokenBuilder = $tokenInfo->toBuilder();
$tokenBuilder->removeUserId();
$tokenBuilder->removeSessionToken();
$tokenBuilder->removeImpersonatedUserId();
$tokenInfo = $tokenBuilder->toInfo();
2022-09-13 13:14:49 +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'));;