<?php
/**
 * GET /api/v1/me.php
 *
 * Returns the authenticated user's profile. Useful for verifying a stored
 * token is still valid on app launch (before unlocking via biometrics).
 */

require_once __DIR__ . '/../../config.php';
require_once __DIR__ . '/../../lib/api.php';

api_require_method('GET');
$user = api_auth($pdo);

api_ok([
    'user' => [
        'id'          => $user['id'],
        'username'    => $user['username'],
        'full_name'   => $user['full_name'],
        'role'        => perms_role($user),
        'facility_id' => $user['facility_id'],
    ],
]);
