<?php
namespace Misuzu;

use Misuzu\Auth\AuthTokenCookie;

if(CSRF::validateRequest()) {
    $tokenInfo = $msz->getAuthInfo()->getTokenInfo();

    if($tokenInfo->hasImpersonatedUserId()) {
        $impUserId = $tokenInfo->getImpersonatedUserId();

        $tokenBuilder = $tokenInfo->toBuilder();
        $tokenBuilder->removeImpersonatedUserId();
        $tokenInfo = $tokenBuilder->toInfo();

        AuthTokenCookie::apply($tokenPacker->pack($tokenInfo));
        url_redirect('manage-user', ['user' => $impUserId]);
        return;
    }
}

url_redirect('index');
