<?php
require_once '../../../app/db.php';
require_once '../../../app/jwt.php';

$headers = getallheaders();

if (!isset($headers['Authorization'])) {
    http_response_code(401);
    echo json_encode(['error' => 'Token required']);
    exit;
}

$token = str_replace('Bearer ', '', $headers['Authorization']);
$driver_id = validateJWT($token);

if (!$driver_id) {
    http_response_code(401);
    echo json_encode(['error' => 'Invalid token']);
    exit;
}
