Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.141.32.16
<?php
function getAuthToken(){
require 'jwt.php';
$headers = apache_request_headers();
$authHeader = isset($headers['Authorization']) ? $headers['Authorization'] : '';
if ($authHeader) {
list($type, $jwt) = explode(' ', $authHeader);
if ($type === 'Bearer' && verify_jwt($jwt, $secret_key)) {
handleLoginNew();
echo json_encode(['message' => 'Access granted']);
} else {
http_response_code(401);
echo json_encode(['error' => 'Invalid token']);
}
} else {
http_response_code(401);
echo json_encode(['error' => 'No token provided']);
}
}
?>
|