<?php
// =============================================================
//  GET /api/v1/auth/me
//
//  Returns the authenticated account's profile — the same shape
//  auth/login.php's data.user returns, so the client can refresh its
//  cached profile (e.g. after a role/scope change) without a full
//  re-login.
// =============================================================

require_once __DIR__ . '/../_bootstrap.php';
require_once __DIR__ . '/_helpers.php';

if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
    Api::error(405, 'MethodNotAllowed', 'Use GET');
}

$account = api_authenticate();
Api::success(['user' => api_build_profile($conn, $account)]);
