diff --git a/backend/auth/syria/uploadImage.php b/backend/auth/syria/uploadImage.php index e1ba801..697bca3 100644 --- a/backend/auth/syria/uploadImage.php +++ b/backend/auth/syria/uploadImage.php @@ -5,10 +5,7 @@ // يخزّنها في مجلدات حسب الدولة: auth/uploads/{country}/ // ============================================================ -// ملاحظة: نستخدم bootstrap.php مباشرة (بدون connect.php) لأن JWT -// registration (token_type: registration) لا يملك صلاحية connect.php -require_once __DIR__ . '/../../core/bootstrap.php'; -$con = Database::get('main'); +require_once __DIR__ . '/../../connect.php'; uploadLog("🚀 [uploadImage.php] Document upload started."); diff --git a/backend/core/Auth/JwtService.php b/backend/core/Auth/JwtService.php index 02ed73b..3a12418 100644 --- a/backend/core/Auth/JwtService.php +++ b/backend/core/Auth/JwtService.php @@ -33,6 +33,7 @@ class JwtService 'loginFromGooglePassenger', 'loginUsingCredentialsWithoutGooglePassenger', 'register', 'sendOtpMessageDriver', 'getTokensPassenger', 'send_otp', 'verify_otp', 'errorApp', 'register_driver', + 'uploadImage', 'register_driver_and_car', ]; public function __construct(?Redis $redis = null) diff --git a/siro_driver/lib/controller/auth/syria/registration_controller.dart b/siro_driver/lib/controller/auth/syria/registration_controller.dart index f3d671e..fd457b7 100644 --- a/siro_driver/lib/controller/auth/syria/registration_controller.dart +++ b/siro_driver/lib/controller/auth/syria/registration_controller.dart @@ -359,11 +359,11 @@ class RegistrationController extends GetxController { String link, { String? backupLink, }) async { - const int maxRetries = 3; - final List urlsToTry = [link, if (backupLink != null && backupLink.trim().isNotEmpty) backupLink]; - for (final currentUrl in urlsToTry) { + for (int i = 0; i < urlsToTry.length; i++) { + final currentUrl = urlsToTry[i]; + final maxRetries = (i == 0) ? 3 : 1; // 3 attempts for primary, 1 for backup for (int attempt = 1; attempt <= maxRetries; attempt++) { try { final uri = Uri.parse(currentUrl); @@ -399,7 +399,15 @@ class RegistrationController extends GetxController { } final body = jsonDecode(res.body); - final String? url = body['url'] ?? + String? url; + // بعض السيرفرات تعيد الرابط داخل message + if (body['message'] is Map) { + url = body['message']['url'] ?? + body['message']['file_link'] ?? + body['message']['image_url']; + } + // وإلا حاول من الجذر + url ??= body['url'] ?? body['file_link'] ?? body['image_url'] ?? (body['data'] is Map ? body['data']['url'] : null);