Update: 2026-07-12 18:53:59
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
require_once __DIR__ . '/../../core/bootstrap.php';
|
||||
require_once __DIR__ . '/../functions.php';
|
||||
|
||||
// Rate limiting — حد صارم على طلبات OTP
|
||||
$limiter = new RateLimiter($redis);
|
||||
$limiter->enforce(RateLimiter::identifier(), 'api');
|
||||
|
||||
try { $transit_con = Database::get('transit'); }
|
||||
catch (Exception $e) { jsonError('Transit service unavailable', 503); }
|
||||
|
||||
@@ -13,7 +17,8 @@ if (!$rawPhone) jsonError('Phone is required');
|
||||
$phone = normalizePhone($rawPhone);
|
||||
|
||||
if (transitIsOtpLocked($phone)) {
|
||||
jsonError('Too many attempts. Try again in 30 minutes.', 429);
|
||||
// نفس رسالة النجاح — لا نكشف أن الحساب مقفل
|
||||
jsonSuccess(null, 'OTP sent successfully');
|
||||
}
|
||||
|
||||
$phoneEnc = $encryptionHelper->encryptData($phone);
|
||||
@@ -26,8 +31,10 @@ $st = $transit_con->prepare(
|
||||
$st->execute([$phoneEnc]);
|
||||
$admin = $st->fetch();
|
||||
|
||||
if (!$admin) jsonError('Invalid credentials', 401);
|
||||
if ($admin['contract_status'] === 'terminated') jsonError('Account suspended', 403);
|
||||
// لا نكشف إن كان الهاتف موجوداً أم لا — نفس الرد دائماً
|
||||
if (!$admin || $admin['contract_status'] === 'terminated') {
|
||||
jsonSuccess(null, 'OTP sent successfully');
|
||||
}
|
||||
|
||||
transitSendAdminOtp($phone);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user