Update: 2026-07-12 05:40:28

This commit is contained in:
Hamza-Ayed
2026-07-12 05:40:28 +03:00
parent 1fa517acc9
commit 24fb56f08f
75 changed files with 5051 additions and 9 deletions
+34
View File
@@ -0,0 +1,34 @@
<?php
// transit/admin/login_request.php — الخطوة 1: هاتف المشرف → OTP
// POST: phone
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); }
$rawPhone = filterRequest('phone');
if (!$rawPhone) jsonError('Phone is required');
$phone = normalizePhone($rawPhone);
if (transitIsOtpLocked($phone)) {
jsonError('Too many attempts. Try again in 30 minutes.', 429);
}
$phoneEnc = $encryptionHelper->encryptData($phone);
$st = $transit_con->prepare(
"SELECT a.id, o.contract_status
FROM transit_org_admins a
JOIN transit_orgs o ON o.id = a.org_id
WHERE a.phone = ? AND a.is_active = 1 LIMIT 1"
);
$st->execute([$phoneEnc]);
$admin = $st->fetch();
if (!$admin) jsonError('Invalid credentials', 401);
if ($admin['contract_status'] === 'terminated') jsonError('Account suspended', 403);
transitSendAdminOtp($phone);
jsonSuccess(null, 'OTP sent successfully');