2023-05-21 18:15:04 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
2023-08-03 01:35:08 +00:00
|
|
|
use Misuzu\Auth\AuthTokenCookie;
|
|
|
|
|
2024-12-02 02:28:08 +00:00
|
|
|
if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|
|
|
die('Script must be called through the Misuzu route dispatcher.');
|
|
|
|
|
2023-08-03 01:35:08 +00:00
|
|
|
if(CSRF::validateRequest()) {
|
2024-11-30 04:09:29 +00:00
|
|
|
$tokenInfo = $msz->authInfo->tokenInfo;
|
2023-08-03 01:35:08 +00:00
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
if($tokenInfo->hasImpersonatedUserId) {
|
|
|
|
$impUserId = $tokenInfo->impersonatedUserId;
|
2023-05-21 18:15:04 +00:00
|
|
|
|
2023-08-03 01:35:08 +00:00
|
|
|
$tokenBuilder = $tokenInfo->toBuilder();
|
|
|
|
$tokenBuilder->removeImpersonatedUserId();
|
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
$tokenInfo = $tokenBuilder->toInfo();
|
2024-12-02 02:28:08 +00:00
|
|
|
AuthTokenCookie::apply($msz->authCtx->createAuthTokenPacker()->pack($tokenInfo));
|
2024-11-30 04:09:29 +00:00
|
|
|
Tools::redirect($msz->urls->format('manage-user', ['user' => $impUserId]));
|
2023-08-03 01:35:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2023-05-21 18:15:04 +00:00
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
Tools::redirect($msz->urls->format('index'));
|