Actualiser api/config.php
This commit is contained in:
+11
-2
@@ -76,8 +76,17 @@ function verifyToken($token) {
|
||||
|
||||
// Fonction pour obtenir l'utilisateur actuel
|
||||
function getCurrentUser() {
|
||||
$headers = getallheaders();
|
||||
$authHeader = $headers['Authorization'] ?? '';
|
||||
$authHeader = '';
|
||||
|
||||
// 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)) {
|
||||
$token = $matches[1];
|
||||
|
||||
Reference in New Issue
Block a user