25-3/18/1

This commit is contained in:
Hamza-Ayed
2025-03-18 13:54:27 +03:00
parent 6e77dec65f
commit 153d2f64c0
1307 changed files with 9505 additions and 528 deletions

55
lib/controller/auth/captin/login_captin_controller.dart Normal file → Executable file
View File

@@ -102,18 +102,23 @@ class LoginDriverController extends GetxController {
} else {
await SecurityChecks.isDeviceRootedFromNative(Get.context!);
}
String fingerPrint = await getDeviceFingerprint();
String fingerPrint = await DeviceHelper.getDeviceFingerprint();
dev = Platform.isAndroid ? 'android' : 'ios';
var payload = {
'id': box.read(BoxName.passengerID),
'id': box.read(BoxName.driverID),
'password': AK.passnpassenger,
'aud': '${AK.allowed}$dev',
'aud': '${AK.allowedWallet}$dev',
'fingerPrint': fingerPrint
};
var response1 = await http.post(
Uri.parse(AppLink.loginJwtWalletDriver),
body: payload,
);
Log.print('response.request: ${response1.request}');
Log.print('response.body: ${response1.body}');
print(payload);
Log.print(
'jsonDecode(response1.body)["jwt"]: ${jsonDecode(response1.body)['jwt']}');
return jsonDecode(response1.body)['jwt'].toString();
}
@@ -155,6 +160,7 @@ class LoginDriverController extends GetxController {
} else {}
} else {
await EncryptionHelper.initialize();
var emailDecrypted = (box.read(BoxName.emailDriver));
var pass = passwordController.text.isEmpty
? '$emailDecrypted${box.read(BoxName.driverID)}'
@@ -246,7 +252,10 @@ class LoginDriverController extends GetxController {
if (jsonDecoeded.isNotEmpty) {
if (jsonDecoeded['status'] == 'success' &&
jsonDecoeded['data'][0]['is_verified'].toString() == '1') {
box.write(BoxName.emailDriver, (jsonDecoeded['data'][0]['email']));
box.write(
BoxName.emailDriver,
EncryptionHelper.instance
.decryptData(jsonDecoeded['data'][0]['email']));
box.write(BoxName.firstTimeLoadKey, 'false');
box.write(BoxName.driverID, (jsonDecoeded['data'][0]['id']));
box.write(BoxName.isTest, '1');
@@ -302,11 +311,12 @@ class LoginDriverController extends GetxController {
link: AppLink.getDriverToken,
payload: {'captain_id': (box.read(BoxName.driverID)).toString()});
String? fingerPrint = await DeviceHelper.getDeviceFingerprint();
await storage.write(key: BoxName.fingerPrint, value: fingerPrint);
if (token != 'failure') {
if (EncryptionHelper.instance
.decryptData(jsonDecode(token)['data'][0]['token']) !=
EncryptionHelper.instance
.decryptData(box.read(BoxName.tokenDriver))) {
if ((jsonDecode(token)['data'][0]['token']) !=
(box.read(BoxName.tokenDriver))) {
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
'token change'.tr,
'change device'.tr,
@@ -315,7 +325,7 @@ class LoginDriverController extends GetxController {
.toString(),
[],
'promo.wav');
Get.defaultDialog(
await Get.defaultDialog(
title: 'you will use this device?'.tr,
middleText: '',
confirm: MyElevatedButton(
@@ -324,7 +334,8 @@ class LoginDriverController extends GetxController {
await CRUD()
.post(link: AppLink.addTokensDriver, payload: {
'token': (box.read(BoxName.tokenDriver)),
'captain_id': (box.read(BoxName.driverID)).toString()
'captain_id': (box.read(BoxName.driverID)).toString(),
'fingerPrint': (fingerPrint).toString()
});
await CRUD().post(
link:
@@ -332,7 +343,8 @@ class LoginDriverController extends GetxController {
payload: {
'token': (box.read(BoxName.tokenDriver)),
'captain_id':
(box.read(BoxName.driverID)).toString()
(box.read(BoxName.driverID)).toString(),
'fingerPrint': (fingerPrint).toString()
});
// await CRUD().post(
// link:
@@ -372,8 +384,7 @@ class LoginDriverController extends GetxController {
'email': EncryptionHelper.instance.encryptData(email),
'password': password,
});
box.write(BoxName.emailDriver,
EncryptionHelper.instance.decryptData(email).toString());
box.write(BoxName.emailDriver, (email).toString());
print(res);
if (res == 'failure') {
//Failure
@@ -439,15 +450,16 @@ class LoginDriverController extends GetxController {
}
updateAppTester(AppInformation.appName);
var fingerPrint = DeviceHelper.getDeviceFingerprint().toString();
await storage.write(key: BoxName.fingerPrint, value: fingerPrint);
var token = await CRUD().get(
link: AppLink.getDriverToken,
payload: {'captain_id': box.read(BoxName.driverID).toString()});
if (token != 'failure') {
if (EncryptionHelper.instance
.decryptData(jsonDecode(token)['data'][0]['token']) !=
EncryptionHelper.instance
.decryptData(box.read(BoxName.tokenDriver))) {
if ((jsonDecode(token)['data'][0]['token']) !=
(box.read(BoxName.tokenDriver))) {
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
'token change'.tr,
'change device'.tr,
@@ -465,7 +477,8 @@ class LoginDriverController extends GetxController {
await CRUD()
.post(link: AppLink.addTokensDriver, payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id': box.read(BoxName.driverID).toString()
'captain_id': box.read(BoxName.driverID).toString(),
'fingerPrint': (fingerPrint).toString()
});
await CRUD().post(
link:
@@ -473,7 +486,8 @@ class LoginDriverController extends GetxController {
payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id':
box.read(BoxName.driverID).toString()
box.read(BoxName.driverID).toString(),
'fingerPrint': (fingerPrint).toString()
});
await CRUD().post(
link:
@@ -481,7 +495,8 @@ class LoginDriverController extends GetxController {
payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id':
box.read(BoxName.driverID).toString()
box.read(BoxName.driverID).toString(),
'fingerPrint': (fingerPrint).toString()
});
Get.back();
}));