new backend and more secure 29-04-2026
This commit is contained in:
@@ -54,7 +54,8 @@ class CRUD {
|
||||
final phone = box.read(BoxName.phone) ?? box.read(BoxName.phoneDriver);
|
||||
|
||||
// طباعة الخطأ في الكونسول للمطور للمتابعة الفورية
|
||||
Log.print("🚨 [ADD_ERROR] Where: $where | Error: $error | Details: $details");
|
||||
Log.print(
|
||||
"🚨 [ADD_ERROR] Where: $where | Error: $error | Details: $details");
|
||||
|
||||
// Fire-and-forget call to prevent infinite loops if the logger itself fails.
|
||||
CRUD().post(
|
||||
@@ -114,6 +115,9 @@ class CRUD {
|
||||
final body = response.body;
|
||||
Log.print('request: ${response.request}');
|
||||
Log.print('body: $body');
|
||||
// Log.print('link: $link');
|
||||
Log.print('headers: $headers');
|
||||
Log.print('payload: $payload');
|
||||
|
||||
// 2xx
|
||||
if (sc >= 200 && sc < 300) {
|
||||
@@ -212,29 +216,34 @@ class CRUD {
|
||||
if (jsonData['error'] == 'Token expired') {
|
||||
print("CRUD.get: Token expired, refreshing and retrying once...");
|
||||
await Get.put(LoginController()).getJWT();
|
||||
|
||||
|
||||
// إعادة المحاولة مرة واحدة فقط بتوكن جديد
|
||||
var retryResponse = await http.post(
|
||||
url,
|
||||
body: payload,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Authorization': 'Bearer ${r(box.read(BoxName.jwt)).toString().split(Env.addd)[0]}',
|
||||
'Authorization':
|
||||
'Bearer ${r(box.read(BoxName.jwt)).toString().split(Env.addd)[0]}',
|
||||
'X-Device-FP': _getFpHeader(),
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
if (retryResponse.statusCode == 200) {
|
||||
return retryResponse.body;
|
||||
return retryResponse.body;
|
||||
}
|
||||
return jsonEncode({'status': 'failure', 'message': 'token_expired_retry_failed'});
|
||||
return jsonEncode(
|
||||
{'status': 'failure', 'message': 'token_expired_retry_failed'});
|
||||
} else {
|
||||
return jsonEncode({'status': 'failure', 'message': '401_unauthorized'});
|
||||
}
|
||||
} else {
|
||||
addError('Non-200 response code: ${response.statusCode}',
|
||||
'crud().get - Other', url.toString());
|
||||
return jsonEncode({'status': 'failure', 'message': 'server_error_${response.statusCode}'});
|
||||
return jsonEncode({
|
||||
'status': 'failure',
|
||||
'message': 'server_error_${response.statusCode}'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,6 +266,10 @@ class CRUD {
|
||||
'X-HMAC-Auth': hmac.toString(),
|
||||
'X-Device-FP': _getFpHeader(), // ← إثبات الجهاز
|
||||
};
|
||||
// add print debug
|
||||
Log.print('headers: $headers');
|
||||
Log.print('payload: $payload');
|
||||
Log.print('link: $link');
|
||||
|
||||
return await _makeRequest(
|
||||
link: link,
|
||||
@@ -711,7 +724,8 @@ class CRUD {
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
return jsonDecode(response.body);
|
||||
}
|
||||
Log.print('MapSaas Post Error: ${response.statusCode} - ${response.body}');
|
||||
Log.print(
|
||||
'MapSaas Post Error: ${response.statusCode} - ${response.body}');
|
||||
return null;
|
||||
} catch (e) {
|
||||
Log.print('MapSaas Post Exception: $e');
|
||||
|
||||
Reference in New Issue
Block a user