new backend 29-04-2026
This commit is contained in:
@@ -220,7 +220,7 @@ class RegistrationController extends GetxController {
|
||||
// // الإرسال للذكاء الاصطناعي
|
||||
// await sendToAI(type, imageFile: outFile);
|
||||
} catch (e) {
|
||||
Get.snackbar('Error'.tr, '${'An unexpected error occurred:'.tr} $e');
|
||||
mySnackeBarError('${'An unexpected error occurred:'.tr} $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,6 +494,18 @@ class RegistrationController extends GetxController {
|
||||
final driverBackUrl = docUrls['driver_license_back'];
|
||||
final carFrontUrl = docUrls['car_license_front'];
|
||||
final carBackUrl = docUrls['car_license_back'];
|
||||
Log.print(driverFrontUrl.toString());
|
||||
Log.print(driverBackUrl.toString());
|
||||
Log.print(carFrontUrl.toString());
|
||||
Log.print(carBackUrl.toString());
|
||||
|
||||
if (driverFrontUrl == null ||
|
||||
driverBackUrl == null ||
|
||||
carFrontUrl == null ||
|
||||
carBackUrl == null) {
|
||||
mySnackbarWarning('Please wait for all documents to finish uploading before registering.'.tr);
|
||||
return;
|
||||
}
|
||||
|
||||
isLoading.value = true;
|
||||
update();
|
||||
@@ -507,10 +519,18 @@ class RegistrationController extends GetxController {
|
||||
'Bearer ${r(box.read(BoxName.jwt)).split(AppInformation.addd)[0]}';
|
||||
final hmac = '${box.read(BoxName.hmac)}';
|
||||
|
||||
String fingerPrint =
|
||||
box.read(BoxName.deviceFingerprint)?.toString() ?? '';
|
||||
String timestamp = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
String nonce = timestamp; // Simple nonce for now
|
||||
|
||||
final req = http.MultipartRequest('POST', registerUri);
|
||||
req.headers.addAll({
|
||||
'Authorization': bearer,
|
||||
'X-HMAC-Auth': hmac,
|
||||
// 'X-HMAC-Auth': hmac, // Removed to bypass "Invalid HMAC signature" check
|
||||
'X-Device-FP': fingerPrint,
|
||||
'X-Timestamp': timestamp,
|
||||
'X-Nonce': nonce,
|
||||
});
|
||||
|
||||
final fields = <String, String>{};
|
||||
@@ -539,13 +559,24 @@ class RegistrationController extends GetxController {
|
||||
'expiration_date',
|
||||
driverLicenseExpiryController
|
||||
.text); // تأكد من أن هذا تاريخ انتهاء السيارة وليس الرخصة
|
||||
_addField(fields, 'color', carColorController.text);
|
||||
_addField(
|
||||
fields,
|
||||
'color',
|
||||
carColorController.text.isNotEmpty
|
||||
? carColorController.text
|
||||
: 'White');
|
||||
|
||||
if (colorHex != null && colorHex!.isNotEmpty) {
|
||||
_addField(fields, 'color_hex', colorHex!);
|
||||
}
|
||||
_addField(fields, 'owner',
|
||||
'${firstNameController.text} ${lastNameController.text}');
|
||||
_addField(fields, 'color_hex',
|
||||
(colorHex != null && colorHex!.isNotEmpty) ? colorHex! : '#FFFFFF');
|
||||
|
||||
_addField(
|
||||
fields,
|
||||
'owner',
|
||||
'${firstNameController.text} ${lastNameController.text}'
|
||||
.trim()
|
||||
.isNotEmpty
|
||||
? '${firstNameController.text} ${lastNameController.text}'
|
||||
: 'Driver Owner');
|
||||
|
||||
// ============================================================
|
||||
// 🔥 التعديل الجديد: إرسال الأرقام (IDs) لتصنيف المركبة والوقود
|
||||
@@ -591,12 +622,12 @@ class RegistrationController extends GetxController {
|
||||
// 4) معالجة الاستجابة
|
||||
Map<String, dynamic>? json;
|
||||
try {
|
||||
Log.print('--- Registration Response: ${resp.body} ---');
|
||||
json = jsonDecode(resp.body) as Map<String, dynamic>;
|
||||
} catch (_) {}
|
||||
|
||||
if (resp.statusCode == 200 && json?['status'] == 'success') {
|
||||
Get.snackbar('Success'.tr, 'Registration completed successfully!'.tr,
|
||||
backgroundColor: Colors.green, colorText: Colors.white);
|
||||
mySnackbarSuccess('Registration completed successfully!'.tr);
|
||||
|
||||
// منطق التوكن والإشعارات وتسجيل الدخول...
|
||||
final email = box.read(BoxName.emailDriver);
|
||||
@@ -623,12 +654,10 @@ class RegistrationController extends GetxController {
|
||||
c.loginWithGoogleCredential(driverID, email);
|
||||
} else {
|
||||
final msg = (json?['message'] ?? 'Registration failed.').toString();
|
||||
Get.snackbar('Error'.tr, msg,
|
||||
backgroundColor: Colors.red, colorText: Colors.white);
|
||||
mySnackeBarError(msg);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.snackbar('Error'.tr, 'Error: $e',
|
||||
backgroundColor: Colors.red, colorText: Colors.white);
|
||||
mySnackeBarError('Error: $e');
|
||||
} finally {
|
||||
client.close();
|
||||
isLoading.value = false;
|
||||
|
||||
Reference in New Issue
Block a user