Update: 2026-07-12 18:53:59

This commit is contained in:
Hamza-Ayed
2026-07-12 18:53:59 +03:00
parent 8cd4a4b57e
commit 653d73422f
54 changed files with 2078 additions and 436 deletions
+34
View File
@@ -0,0 +1,34 @@
<?php
// transit/admin/logout.php — تسجيل خروج مشرف المؤسسة (حذف الجلسة)
// POST: — (التوكن في الهيدر Authorization: Bearer)
require_once __DIR__ . '/../../core/bootstrap.php';
require_once __DIR__ . '/../functions.php';
try { $transit_con = Database::get('transit'); }
catch (Exception $e) { jsonError('Transit service unavailable', 503); }
// استخرج التوكن من الهيدر
$authHeader = $_SERVER['HTTP_AUTHORIZATION'] ?? '';
$token = '';
if (preg_match('/Bearer\s+(\S+)/i', $authHeader, $m)) {
$token = $m[1];
} else {
$token = filterRequest('token') ?? '';
}
if (!$token) jsonError('No session token provided', 400);
$hash = hash('sha256', $token);
// حذف من Redis
if ($redis) $redis->del("siro:transit:session:{$hash}");
// حذف من MySQL
try {
$transit_con->prepare("DELETE FROM transit_sessions WHERE token_hash=?")->execute([$hash]);
} catch (Throwable $e) {
// لا بأس — الجلسة انتهت بالـ Redis
}
jsonSuccess(null, 'Logged out successfully');