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
|
|
|
|
|
|
|
$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
|
|
|
|
2023-08-03 01:35:08 +00:00
|
|
|
AuthTokenCookie::apply($tokenPacker->pack($tokenInfo));
|
2022-09-13 13:14:49 +00:00
|
|
|
}
|
|
|
|
|
2023-08-03 01:35:08 +00:00
|
|
|
url_redirect('index');
|