25 lines
757 B
PHP
25 lines
757 B
PHP
<?php
|
|
namespace Misuzu;
|
|
|
|
use Misuzu\Auth\AuthTokenCookie;
|
|
|
|
if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|
die('Script must be called through the Misuzu route dispatcher.');
|
|
|
|
if(CSRF::validateRequest()) {
|
|
$tokenInfo = $msz->authInfo->tokenInfo;
|
|
|
|
if($tokenInfo->hasImpersonatedUserId) {
|
|
$impUserId = $tokenInfo->impersonatedUserId;
|
|
|
|
$tokenBuilder = $tokenInfo->toBuilder();
|
|
$tokenBuilder->removeImpersonatedUserId();
|
|
|
|
$tokenInfo = $tokenBuilder->toInfo();
|
|
AuthTokenCookie::apply($msz->authCtx->createAuthTokenPacker()->pack($tokenInfo));
|
|
Tools::redirect($msz->urls->format('manage-user', ['user' => $impUserId]));
|
|
return;
|
|
}
|
|
}
|
|
|
|
Tools::redirect($msz->urls->format('index'));
|