misuzu/public-legacy/auth/logout.php

26 lines
623 B
PHP
Raw Permalink Normal View History

2022-09-13 13:14:49 +00:00
<?php
namespace Misuzu;
use Misuzu\Auth\AuthTokenCookie;
if($msz->isLoggedIn()) {
if(!CSRF::validateRequest()) {
Template::render('auth.logout');
return;
}
$tokenInfo = $msz->getAuthInfo()->getTokenInfo();
$msz->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
}
url_redirect('index');