admin-portal/tech/api/_authenticateApiRequest.php
Frederico Falcao f2a6525224 init
2025-05-30 10:46:17 +01:00

17 lines
354 B
PHP

<?php
$apiToken = '2fce';
$headers = getallheaders();
$authHeader = $headers['Authorization'] ?? '';
if (!preg_match('/Bearer\s(\S+)/', $authHeader, $matches) || $apiToken !== $matches[1]) {
// ❌ Unauthorized
http_response_code(401);
header('Content-Type: application/json');
echo json_encode(['error' => 'Unauthorized']);
exit;
}