25-6-23/1
This commit is contained in:
@@ -94,9 +94,9 @@ class CRUD {
|
||||
'X-HMAC-Auth': hmac.toString(),
|
||||
},
|
||||
);
|
||||
Log.print('response.request: ${response.request}');
|
||||
Log.print('response.body: ${response.body}');
|
||||
print(payload);
|
||||
// Log.print('response.request: ${response.request}');
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
if (response.statusCode == 200) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
@@ -128,11 +128,13 @@ class CRUD {
|
||||
Future<dynamic> postWallet(
|
||||
{required String link, Map<String, dynamic>? payload}) async {
|
||||
var s = await LoginDriverController().getJwtWallet();
|
||||
// Log.print('jwt: ${s}');
|
||||
final hmac = box.read(BoxName.hmac);
|
||||
Log.print('hmac: ${hmac}');
|
||||
// Log.print('hmac: ${hmac}');
|
||||
var url = Uri.parse(link);
|
||||
// Log.print('url: ${url}');
|
||||
try {
|
||||
await LoginDriverController().getJWT();
|
||||
// await LoginDriverController().getJWT();
|
||||
|
||||
var response = await http.post(
|
||||
url,
|
||||
@@ -143,9 +145,9 @@ class CRUD {
|
||||
'X-HMAC-Auth': hmac.toString(),
|
||||
},
|
||||
);
|
||||
print(response.request);
|
||||
Log.print('response.body: ${response.body}');
|
||||
print(payload);
|
||||
// Log.print('response.request:${response.request}');
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// Log.print('payload:$payload');
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
@@ -201,9 +203,9 @@ class CRUD {
|
||||
// 'Authorization': 'Bearer ${box.read(BoxName.jwt)}'
|
||||
},
|
||||
);
|
||||
print(response.request);
|
||||
Log.print('response.body: ${response.body}');
|
||||
print(payload);
|
||||
// print(response.request);
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
@@ -439,22 +441,46 @@ class CRUD {
|
||||
}
|
||||
}
|
||||
|
||||
sendEmail(
|
||||
String link,
|
||||
Map<String, String>? payload,
|
||||
) async {
|
||||
var headers = {
|
||||
Future<void> sendEmail(String link, Map<String, String>? payload) async {
|
||||
// التحقق من صلاحية التوكن
|
||||
String rawJwt = box.read(BoxName.jwt);
|
||||
String token = X
|
||||
.r(X.r(X.r(rawJwt, cn), cC), cs)
|
||||
.toString()
|
||||
.split(AppInformation.addd)[0];
|
||||
|
||||
bool isTokenExpired = JwtDecoder.isExpired(token);
|
||||
if (isTokenExpired) {
|
||||
await LoginDriverController().getJWT();
|
||||
rawJwt = box.read(BoxName.jwt); // تحديث التوكن بعد التجديد
|
||||
token = X
|
||||
.r(X.r(X.r(rawJwt, cn), cC), cs)
|
||||
.toString()
|
||||
.split(AppInformation.addd)[0];
|
||||
}
|
||||
|
||||
// إعداد الهيدر
|
||||
final headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
|
||||
"Authorization": "Bearer $token",
|
||||
};
|
||||
var request = http.Request('POST', Uri.parse(link));
|
||||
request.bodyFields = payload!;
|
||||
|
||||
// إعداد الطلب
|
||||
final request = http.Request('POST', Uri.parse(link));
|
||||
request.bodyFields = payload ?? {};
|
||||
request.headers.addAll(headers);
|
||||
|
||||
http.StreamedResponse response = await request.send();
|
||||
// إرسال الطلب
|
||||
final response = await request.send();
|
||||
|
||||
// التحقق من النتيجة
|
||||
if (response.statusCode == 200) {
|
||||
} else {}
|
||||
print("✅ Email sent successfully.");
|
||||
} else {
|
||||
print("❌ Failed to send email. Status: ${response.statusCode}");
|
||||
final responseBody = await response.stream.bytesToString();
|
||||
print("Response body: $responseBody");
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> postFromDialogue({
|
||||
|
||||
@@ -105,7 +105,7 @@ class AI extends GetxController {
|
||||
NotificationController().showNotification(
|
||||
"Code approved".tr, "Code approved".tr, 'tone2', '');
|
||||
// Notification text with dynamic token
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
|
||||
'You have received a gift token!'.tr,
|
||||
'for '.tr + box.read(BoxName.phoneDriver).toString(),
|
||||
jsonDecode(res)['message'][0]['token'].toString(),
|
||||
|
||||
@@ -133,8 +133,8 @@ class LocationController extends GetxController {
|
||||
|
||||
// ✅ إدخال للسيرفر كل دقيقة
|
||||
_insertCounter++;
|
||||
Log.print('_insertCounter: ${_insertCounter}');
|
||||
if (_insertCounter >= 12) {
|
||||
// Log.print('_insertCounter: ${_insertCounter}');
|
||||
if (_insertCounter == 12) {
|
||||
_insertCounter = 0;
|
||||
await CRUD().post(
|
||||
link: box.read(BoxName.serverChosen) + '/ride/location/add.php',
|
||||
|
||||
@@ -247,15 +247,15 @@ class SecurityHelper {
|
||||
await box.write('isTampered', isTampered); // Use await
|
||||
await box.write('isJailBroken', isJailBroken); // Use await
|
||||
|
||||
debugPrint("Security Check Results:");
|
||||
debugPrint("isNotTrust: $isNotTrust");
|
||||
debugPrint("isJailBroken: $isJailBroken");
|
||||
debugPrint("isRealDevice: $isRealDevice");
|
||||
debugPrint("isOnExternalStorage: $isOnExternalStorage");
|
||||
debugPrint("checkForIssues: $checkForIssues");
|
||||
debugPrint("isDevMode: $isDevMode");
|
||||
debugPrint("isTampered: $isTampered");
|
||||
debugPrint("Bundle ID: $bundleId"); // Print the bundle ID
|
||||
// debugPrint("Security Check Results:");
|
||||
// debugPrint("isNotTrust: $isNotTrust");
|
||||
// debugPrint("isJailBroken: $isJailBroken");
|
||||
// debugPrint("isRealDevice: $isRealDevice");
|
||||
// debugPrint("isOnExternalStorage: $isOnExternalStorage");
|
||||
// debugPrint("checkForIssues: $checkForIssues");
|
||||
// debugPrint("isDevMode: $isDevMode");
|
||||
// debugPrint("isTampered: $isTampered");
|
||||
// debugPrint("Bundle ID: $bundleId"); // Print the bundle ID
|
||||
|
||||
// Check for security risks and potentially show a warning
|
||||
if (isJailBroken || isRealDevice == false || isTampered) {
|
||||
|
||||
@@ -40,7 +40,6 @@ class AppInitializer {
|
||||
|
||||
Future<void> initializeApp() async {
|
||||
if (box.read(BoxName.jwt) == null) {
|
||||
Log.print('box.read(BoxName.jwt): ${box.read(BoxName.jwt)}');
|
||||
await LoginDriverController().getJWT();
|
||||
} else {
|
||||
bool isTokenExpired = JwtDecoder.isExpired(X
|
||||
@@ -55,15 +54,18 @@ class AppInitializer {
|
||||
// await getKey();
|
||||
}
|
||||
|
||||
getAIKey(String key1) async {
|
||||
if (box.read(BoxName.firstTimeLoadKey) == null) {
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getapiKey, payload: {"keyName": key1});
|
||||
if (res != 'failure') {
|
||||
var d = jsonDecode(res)['message'];
|
||||
await storage.write(key: key1, value: d[key1].toString());
|
||||
await Future.delayed(Duration.zero);
|
||||
} else {}
|
||||
Future<void> getAIKey(String key1) async {
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getapiKey, payload: {"keyName": key1});
|
||||
|
||||
if (res != 'failure') {
|
||||
var d = jsonDecode(res)['message'];
|
||||
final rawValue = d[key1].toString();
|
||||
|
||||
// ✅ اكتبها في storage
|
||||
await storage.write(key: key1, value: rawValue);
|
||||
|
||||
await Future.delayed(Duration.zero);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user