From bb3536aa90fb29e6a8f8cf7ec7c595133bb11d7c Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Tue, 21 Jul 2026 20:40:48 +0300 Subject: [PATCH] Update: 2026-07-21 20:40:48 --- siro_rider/lib/constant/box_name.dart | 3 +- .../lib/controller/auth/login_controller.dart | 36 +++++++++++-------- .../lib/controller/auth/otp_controller.dart | 12 ++++++- .../controller/functions/upload_image.dart | 5 +-- .../home/profile/complaint_controller.dart | 7 ++-- 5 files changed, 41 insertions(+), 22 deletions(-) diff --git a/siro_rider/lib/constant/box_name.dart b/siro_rider/lib/constant/box_name.dart index 730177a1..6b5f5e6e 100644 --- a/siro_rider/lib/constant/box_name.dart +++ b/siro_rider/lib/constant/box_name.dart @@ -110,6 +110,7 @@ class BoxName { static const String tripData = 'tripData'; static const String parentTripSelected = 'parentTripSelected'; static const String styleVersion = 'styleVersion'; - static const String isDestinationMatch = 'isDestinationMatch'; // 🆕 AI Destination Matching + static const String isDestinationMatch = + 'isDestinationMatch'; // 🆕 AI Destination Matching static const String isPrime = 'isPrime'; // 👑 Siro Prime subscription status } diff --git a/siro_rider/lib/controller/auth/login_controller.dart b/siro_rider/lib/controller/auth/login_controller.dart index bcaa2f36..4478c0dc 100644 --- a/siro_rider/lib/controller/auth/login_controller.dart +++ b/siro_rider/lib/controller/auth/login_controller.dart @@ -127,8 +127,8 @@ class LoginController extends GetxController { if (jwt != null) { // نشفر الـ JWT بالتشفير الثلاثي قبل التخزين في GetStorage - box.write(BoxName.jwt, c(jwt)); - storage.write(key: BoxName.jwt, value: c(jwt)); + box.write(BoxName.jwt, (jwt)); + storage.write(key: BoxName.jwt, value: (jwt)); } await EncryptionHelper.initialize(); @@ -159,8 +159,8 @@ class LoginController extends GetxController { : decoded['jwt']); if (jwt != null) { - box.write(BoxName.jwt, c(jwt)); - storage.write(key: BoxName.jwt, value: c(jwt)); + box.write(BoxName.jwt, (jwt)); + storage.write(key: BoxName.jwt, value: (jwt)); } } } @@ -481,7 +481,8 @@ class LoginController extends GetxController { 'fingerPrint': fingerPrint, 'aud': '${AK.allowed}${Platform.isAndroid ? 'android' : 'ios'}', }; - Log.print("Tester Login Payload: email=${payload['email']}, password=${payload['password']}, aud=${payload['aud']}"); + Log.print( + "Tester Login Payload: email=${payload['email']}, password=${payload['password']}, aud=${payload['aud']}"); var response = await http.post( Uri.parse(AppLink.loginUsingCredentialsWithoutGooglePassenger), @@ -498,8 +499,8 @@ class LoginController extends GetxController { // حفظ التوكن if (jwt != null) { - box.write(BoxName.jwt, c(jwt)); - await storage.write(key: BoxName.jwt, value: c(jwt)); + box.write(BoxName.jwt, (jwt)); + await storage.write(key: BoxName.jwt, value: (jwt)); } box.write(BoxName.isVerified, '1'); @@ -563,33 +564,39 @@ class LoginController extends GetxController { } if (!serviceEnabled) { // Location services are still not enabled, show a message - mySnackbarError('Please enable location services in your device settings to continue.'.tr); + mySnackbarError( + 'Please enable location services in your device settings to continue.' + .tr); return; } } // Check if the app has permission to access location permissionGranted = await location.hasPermission(); - + if (permissionGranted == loc.PermissionStatus.deniedForever) { - mySnackbarError('Please go to app settings and grant location permission.'.tr); + mySnackbarError( + 'Please go to app settings and grant location permission.'.tr); return; } if (permissionGranted == loc.PermissionStatus.denied) { permissionGranted = await location.requestPermission(); - if (permissionGranted != loc.PermissionStatus.granted && permissionGranted != loc.PermissionStatus.grantedLimited) { + if (permissionGranted != loc.PermissionStatus.granted && + permissionGranted != loc.PermissionStatus.grantedLimited) { // Location permission is still not granted, handle the error - mySnackbarError('Location permission is required to use the app. Please grant permission.'.tr); + mySnackbarError( + 'Location permission is required to use the app. Please grant permission.' + .tr); return; } } - + // Initialize geofencing now that we have permission if (Platform.isAndroid || Platform.isIOS) { await SiroGeofencingService.initAndStart(); } - + if (permissionGranted.toString() == 'PermissionStatus.granted' || permissionGranted == loc.PermissionStatus.granted || permissionGranted == loc.PermissionStatus.grantedLimited) { @@ -598,7 +605,6 @@ class LoginController extends GetxController { update(); } - // ───────────────────────────────────────────────────────────── // sendPassengerLocation: تسجيل موقع فتح التطبيق للراكب // ───────────────────────────────────────────────────────────── diff --git a/siro_rider/lib/controller/auth/otp_controller.dart b/siro_rider/lib/controller/auth/otp_controller.dart index 987d6d36..9e28e861 100644 --- a/siro_rider/lib/controller/auth/otp_controller.dart +++ b/siro_rider/lib/controller/auth/otp_controller.dart @@ -6,6 +6,7 @@ import '../../../print.dart'; import '../../views/auth/otp_page.dart'; import '../../views/widgets/error_snakbar.dart'; import '../functions/crud.dart'; +import '../functions/encrypt_decrypt.dart'; import '../functions/package_info.dart'; import '../functions/country_logic.dart'; import 'login_controller.dart'; @@ -16,7 +17,8 @@ class PhoneAuthHelper { // Define your server URLs static final String _sendOtpUrl = '${AppLink.server}/auth/otp/request.php'; static final String _verifyOtpUrl = '${AppLink.server}/auth/otp/verify.php'; - static final String _registerUrl = '${AppLink.server}/auth/passenger/register.php'; + static final String _registerUrl = + '${AppLink.server}/auth/passenger/register.php'; // removed formatSyrianPhone @@ -82,6 +84,14 @@ class PhoneAuthHelper { Log.print('isRegistered: ${isRegistered}'); if (isRegistered) { + final jwtToken = data['message']?['jwt'] ?? + data['message']?['token'] ?? + data['message']?['access_token']; + if (jwtToken != null && jwtToken.toString().isNotEmpty) { + box.write(BoxName.jwt, (jwtToken.toString())); + await storage.write( + key: BoxName.jwt, value: (jwtToken.toString())); + } // ✅ المستخدم موجود مسبقاً -> تسجيل دخول مباشر await _handleSuccessfulLogin(data['message']['passenger']); } else { diff --git a/siro_rider/lib/controller/functions/upload_image.dart b/siro_rider/lib/controller/functions/upload_image.dart index df680048..27c8bfe2 100644 --- a/siro_rider/lib/controller/functions/upload_image.dart +++ b/siro_rider/lib/controller/functions/upload_image.dart @@ -76,10 +76,11 @@ class ImageController extends GetxController { length, filename: basename(file.path), ); - final String fingerPrint = box.read(BoxName.deviceFpEncrypted)?.toString() ?? ''; + final String fingerPrint = + box.read(BoxName.deviceFpEncrypted)?.toString() ?? ''; request.headers.addAll({ 'Authorization': - 'Bearer ${X.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs).toString().split(AppInformation.addd)[0]}', + 'Bearer ${(box.read(BoxName.jwt)).toString().split(AppInformation.addd)[0]}', 'X-Device-FP': fingerPrint, }); // Set the file name to the driverID diff --git a/siro_rider/lib/controller/home/profile/complaint_controller.dart b/siro_rider/lib/controller/home/profile/complaint_controller.dart index f00f52db..91e61149 100644 --- a/siro_rider/lib/controller/home/profile/complaint_controller.dart +++ b/siro_rider/lib/controller/home/profile/complaint_controller.dart @@ -70,8 +70,9 @@ class ComplaintController extends GetxController { var uri = Uri.parse('${AppLink.server}/upload_audio.php'); var request = http.MultipartRequest('POST', uri); - String token = r(box.read(BoxName.jwt)).toString().split(Env.addd)[0]; - final String fingerPrint = box.read(BoxName.deviceFpEncrypted)?.toString() ?? ''; + String token = (box.read(BoxName.jwt)).toString().split(Env.addd)[0]; + final String fingerPrint = + box.read(BoxName.deviceFpEncrypted)?.toString() ?? ''; var mimeType = lookupMimeType(audioFile.path); // ** التعديل: تم استخدام نفس هيدر التوثيق ** @@ -146,7 +147,7 @@ class ComplaintController extends GetxController { // 3. استخراج البيانات المطلوبة final rideId = feedBack[0]['id'].toString(); // ! تأكد أن اسم حقل ID صحيح final complaint = complaintController.text; - String token = r(box.read(BoxName.jwt)).toString().split(Env.addd)[0]; + String token = (box.read(BoxName.jwt)).toString().split(Env.addd)[0]; // 4. استدعاء سكربت PHP الجديد باستخدام http.post final response = await http.post(