Files
intaleq_v3_pure_php/logout.php
2026-04-28 13:04:27 +03:00

24 lines
632 B
PHP

<?php
// logout.php — تسجيل الخروج الآمن وإلغاء التوكن
require_once __DIR__ . '/connect.php';
try {
$jwtService = new JwtService($redis);
$decoded = $jwtService->authenticate();
$jti = $decoded->jti ?? null;
$exp = $decoded->exp ?? 0;
$remaining = $exp - time();
if ($jti && $remaining > 0) {
$jwtService->revokeToken($jti, $remaining);
securityLog("User logged out and token revoked", ['user_id' => $decoded->user_id, 'jti' => $jti]);
}
jsonSuccess(null, "Logged out successfully");
} catch (Exception $e) {
jsonError("Logout failed", 500);
}