Login fertiggestellt im Admin Panel

This commit is contained in:
R40fendt
2026-01-03 21:30:18 +01:00
parent a7cad8edca
commit 3c2c8a368e
2 changed files with 41 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
<?php
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Authorization");
include("../../mysqlverbinden.php");
include("secret.php");
include("../vendor/autoload.php");
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
$token = $_SERVER['HTTP_AUTHORIZATION'] ?? '';
// "Bearer " entfernen
$token = str_replace('Bearer ', '', $token);
try {
$payload=JWT::decode($token, new Key($secret,"HS256"));
if($payload->expire<time()) die('{"error":"Token expired"}');
echo json_encode($payload,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
}catch(Exception $e){
die('{"error":"Invalid Token"}');
}