<?php
declare(strict_types=1);

require_once __DIR__ . '/../../includes/bootstrap.php';
require_once __DIR__ . '/../../includes/CaseStore.php';

dbnToolsRequireMethod('GET');
dbnToolsRequireAuth();

$userId = (int)($_SESSION['dbn_tools_sso_uid'] ?? 0);
if ($userId <= 0) {
    dbnToolsError('Auth required.', 401, 'auth_required');
}

dbnToolsRespond([
    'ok' => true,
    'docs' => CaseStore::listDocs($userId),
]);
