<?php
declare(strict_types=1);

require_once __DIR__ . '/bootstrap.php';
require_once __DIR__ . '/admin_auth_lib.php';

$ok = isset($_SESSION['mocker_admin']) && $_SESSION['mocker_admin'] === true;
$out = [
    'authenticated' => $ok,
    'csrfToken' => mocker_csrf_token(),
];
if ($ok) {
    $out['super'] = mocker_admin_is_super();
    $out['kind'] = (string) ($_SESSION['mocker_admin_kind'] ?? 'master');
    $out['username'] = isset($_SESSION['mocker_admin_username']) ? (string) $_SESSION['mocker_admin_username'] : null;
    $out['displayName'] = isset($_SESSION['mocker_admin_display']) ? (string) $_SESSION['mocker_admin_display'] : null;
    $out['permissions'] = mocker_admin_permission_list();
}
echo json_encode($out, JSON_UNESCAPED_UNICODE);
