Actualiser api/config.php

This commit is contained in:
2026-07-03 20:29:32 +02:00
parent 2fa7e47737
commit a8bc4e6538
+11 -2
View File
@@ -76,8 +76,17 @@ function verifyToken($token) {
// Fonction pour obtenir l'utilisateur actuel // Fonction pour obtenir l'utilisateur actuel
function getCurrentUser() { function getCurrentUser() {
$headers = getallheaders(); $authHeader = '';
$authHeader = $headers['Authorization'] ?? '';
// Détection universelle des headers d'autorisation
if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
$authHeader = $_SERVER['HTTP_AUTHORIZATION'];
} elseif (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
$authHeader = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
} elseif (function_exists('getallheaders')) {
$headers = getallheaders();
$authHeader = $headers['Authorization'] ?? '';
}
if (preg_match('/Bearer\s+(.*)$/i', $authHeader, $matches)) { if (preg_match('/Bearer\s+(.*)$/i', $authHeader, $matches)) {
$token = $matches[1]; $token = $matches[1];