Update: 2026-07-30 02:27:45
This commit is contained in:
@@ -64,8 +64,12 @@ try {
|
||||
exit;
|
||||
}
|
||||
|
||||
// A disabled account must produce the SAME answer as an unknown number,
|
||||
// otherwise this endpoint tells an attacker which phones are registered.
|
||||
if (!$user['is_active']) {
|
||||
json_error('الحساب معطّل. تواصل مع المسؤول.', 403);
|
||||
error_log("OTP request for disabled account: user {$user['id']}");
|
||||
json_success(null, 'إذا كان الرقم مسجلاً، سيتم إرسال رمز التحقق');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 3. Generate OTP (6 digits)
|
||||
@@ -102,16 +106,17 @@ try {
|
||||
$result = $whatsappService->sendMessage($phone, $message);
|
||||
|
||||
if (!$result['success']) {
|
||||
error_log("ERROR: Failed to send OTP WhatsApp to phone: {$phone}");
|
||||
json_error('عذراً، فشل في إرسال رمز التحقق. الرجاء التأكد من صحة رقم الواتساب الخاص بك والمحاولة مرة أخرى.', 500, ['whatsapp_debug' => $result]);
|
||||
// Internal provider details stay in the log, not in the HTTP response.
|
||||
error_log("ERROR: Failed to send OTP WhatsApp to phone: {$phone} - " . json_encode($result));
|
||||
json_error('عذراً، فشل في إرسال رمز التحقق. الرجاء التأكد من صحة رقم الواتساب الخاص بك والمحاولة مرة أخرى.', 500);
|
||||
}
|
||||
|
||||
// Log for development (REMOVE IN PRODUCTION!)
|
||||
// Development only - never reached when APP_DEBUG is false.
|
||||
if (env('APP_DEBUG', 'false') === 'true') {
|
||||
error_log("DEV OTP for {$phone}: {$otp}");
|
||||
}
|
||||
|
||||
json_success(['whatsapp_debug' => $result], 'إذا كان الرقم مسجلاً، سيتم إرسال رمز التحقق عبر واتساب');
|
||||
json_success(null, 'إذا كان الرقم مسجلاً، سيتم إرسال رمز التحقق عبر واتساب');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
safe_error($e, 'auth/mobile_request_otp');
|
||||
|
||||
Reference in New Issue
Block a user