Actualiser api/config.php
This commit is contained in:
+11
-2
@@ -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];
|
||||||
|
|||||||
Reference in New Issue
Block a user