Fix #19: Plaintext OTP hashing + hardcoded server paths

- Changed OTP storage in Admin/auth/login.php from plaintext to sha256 hash
- Updated Admin/auth/verify_login.php to hash user input before comparison
- Replaced hardcoded /home/siro-api/ paths with environment variables:
  - ERROR_LOG_PATH, ENV_FILE_PATH, SECRET_KEY_PAY_PATH, SECRET_KEY_PATH
  - Falls back to __DIR__-relative paths when env vars are unset
This commit is contained in:
Hamza-Ayed
2026-06-17 07:49:46 +03:00
parent 790d58aaa2
commit 2d607d9e90
5 changed files with 15 additions and 19 deletions

View File

@@ -39,14 +39,14 @@ try {
// فك تشفيره لو احتجنا إرساله أو عرضه، لكن هنا نحن نحتاج المشفر للبحث
// $phone = $encryptionHelper->decryptData($encryptedPhone);
// تشفير الرمز (OTP) القادم من التطبيق للمقارنة
$encryptedOtp = $encryptionHelper->encryptData((string)$otp);
// هاش الرمز (OTP) القادم من التطبيق للمقارنة
$otpHash = hash('sha256', (string)$otp);
// 3. التحقق من الـ OTP (باستخدام القيم المشفرة)
// 3. التحقق من الـ OTP
$stmt = $con->prepare("SELECT * FROM token_verification_admin
WHERE phone_number = ? AND token = ?
AND expiration_time >= NOW()");
$stmt->execute([$encryptedPhone, $encryptedOtp]);
$stmt->execute([$encryptedPhone, $otpHash]);
if ($stmt->rowCount() === 0) {
jsonError("رمز التحقق غير صالح أو منتهي الصلاحية.");