25-2/24/1
This commit is contained in:
@@ -47,7 +47,7 @@ class HistoryCaptainController extends GetxController {
|
||||
isloading = true;
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getRideOrderID,
|
||||
payload: {'id': encryptionHelper.encryptData(orderId)});
|
||||
payload: {'id': EncryptionHelper.instance.encryptData(orderId)});
|
||||
historyDetailsData = jsonDecode(res);
|
||||
isloading = false;
|
||||
update();
|
||||
|
||||
@@ -149,9 +149,9 @@ Download the Tripz app now and enjoy your ride!
|
||||
void onSelectDriverInvitation(int index) async {
|
||||
MyDialog().getDialog(
|
||||
int.parse((driverInvitationData[index]['countOfInvitDriver'])) < 100
|
||||
? '${'When'.tr} ${encryptionHelper.decryptData(driverInvitationData[index]['invitorName'])} ${"complete, you can claim your gift".tr} '
|
||||
? '${'When'.tr} ${EncryptionHelper.instance.decryptData(driverInvitationData[index]['invitorName'])} ${"complete, you can claim your gift".tr} '
|
||||
: 'You deserve the gift'.tr,
|
||||
'${encryptionHelper.decryptData(driverInvitationData[index]['invitorName'])} ${(driverInvitationData[index]['countOfInvitDriver'])} / 100 ${'Trip'.tr}',
|
||||
'${EncryptionHelper.instance.decryptData(driverInvitationData[index]['invitorName'])} ${(driverInvitationData[index]['countOfInvitDriver'])} / 100 ${'Trip'.tr}',
|
||||
() async {
|
||||
if (int.parse((driverInvitationData[index]['countOfInvitDriver'])) <
|
||||
100) {
|
||||
@@ -161,23 +161,24 @@ Download the Tripz app now and enjoy your ride!
|
||||
if ((driverInvitationData[index]['isGiftToken']).toString() == '0') {
|
||||
Get.back();
|
||||
await CRUD().post(link: AppLink.updateInviteDriver, payload: {
|
||||
'id': encryptionHelper
|
||||
'id': EncryptionHelper.instance
|
||||
.encryptData(driverInvitationData[index]['id'])
|
||||
});
|
||||
await Get.find<CaptainWalletController>().addDriverPayment(
|
||||
'paymentMethod',
|
||||
encryptionHelper.encryptData('500'),
|
||||
EncryptionHelper.instance.encryptData('500'),
|
||||
'',
|
||||
);
|
||||
// add for invitor too
|
||||
await Get.find<CaptainWalletController>().addDriverWalletToInvitor(
|
||||
'paymentMethod',
|
||||
encryptionHelper
|
||||
EncryptionHelper.instance
|
||||
.encryptData(driverInvitationData[index]['driverInviterId']),
|
||||
encryptionHelper.encryptData('500'),
|
||||
EncryptionHelper.instance.encryptData('500'),
|
||||
);
|
||||
await Get.find<CaptainWalletController>().addSeferWallet(
|
||||
'giftInvitation', encryptionHelper.encryptData('-1000'));
|
||||
'giftInvitation',
|
||||
EncryptionHelper.instance.encryptData('-1000'));
|
||||
NotificationCaptainController().addNotificationCaptain(
|
||||
driverInvitationData[index]['driverInviterId'].toString(),
|
||||
"You have got a gift for invitation".tr,
|
||||
@@ -205,9 +206,9 @@ Download the Tripz app now and enjoy your ride!
|
||||
int.parse(driverInvitationDataToPassengers[index]['countOfInvitDriver']
|
||||
.toString()) <
|
||||
3
|
||||
? '${'When'.tr} ${encryptionHelper.decryptData(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${"complete, you can claim your gift".tr} '
|
||||
? '${'When'.tr} ${EncryptionHelper.instance.decryptData(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${"complete, you can claim your gift".tr} '
|
||||
: 'You deserve the gift'.tr,
|
||||
'${encryptionHelper.decryptData(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${driverInvitationDataToPassengers[index]['countOfInvitDriver']} / 3 ${'Trip'.tr}',
|
||||
'${EncryptionHelper.instance.decryptData(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${driverInvitationDataToPassengers[index]['countOfInvitDriver']} / 3 ${'Trip'.tr}',
|
||||
() async {
|
||||
if (int.parse(driverInvitationDataToPassengers[index]
|
||||
['countOfInvitDriver']
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:secure_string_operations/secure_string_operations.dart';
|
||||
import 'package:sefer_driver/controller/functions/location_background_controller.dart';
|
||||
import 'package:sefer_driver/views/auth/captin/cards/sms_signup.dart';
|
||||
import 'package:sefer_driver/views/widgets/elevated_btn.dart';
|
||||
@@ -15,10 +17,16 @@ import 'package:sefer_driver/main.dart';
|
||||
import 'package:sefer_driver/views/home/Captin/home_captain/home_captin.dart';
|
||||
import 'package:location/location.dart';
|
||||
|
||||
import '../../../constant/api_key.dart';
|
||||
import '../../../constant/char_map.dart';
|
||||
import '../../../constant/info.dart';
|
||||
import '../../../constant/table_names.dart';
|
||||
import '../../../print.dart';
|
||||
import '../../../views/auth/captin/cards/egypt_card_a_i.dart';
|
||||
import '../../firebase/firbase_messge.dart';
|
||||
import '../../functions/encrypt_decrypt.dart';
|
||||
import '../../functions/package_info.dart';
|
||||
import '../../functions/secure_storage.dart';
|
||||
|
||||
class LoginDriverController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
@@ -82,6 +90,77 @@ class LoginDriverController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
var dev = '';
|
||||
getJwtWallet() async {
|
||||
await SecurityHelper.performSecurityChecks();
|
||||
String fingerPrint = await getDeviceFingerprint();
|
||||
dev = Platform.isAndroid ? 'android' : 'ios';
|
||||
var payload = {
|
||||
'id': box.read(BoxName.passengerID),
|
||||
'password': AK.passnpassenger,
|
||||
'aud': '${AK.allowed}$dev',
|
||||
'fingerPrint': fingerPrint
|
||||
};
|
||||
var response1 = await http.post(
|
||||
Uri.parse(AppLink.loginJwtWalletDriver),
|
||||
body: payload,
|
||||
);
|
||||
|
||||
return jsonDecode(response1.body)['jwt'].toString();
|
||||
}
|
||||
|
||||
getJWT() async {
|
||||
// await SecurityHelper.performSecurityChecks();
|
||||
dev = Platform.isAndroid ? 'android' : 'ios';
|
||||
if (box.read(BoxName.firstTimeLoadKey).toString() != 'false') {
|
||||
var response0 = await http.post(
|
||||
Uri.parse(AppLink.loginFirstTimeDriver),
|
||||
body: {
|
||||
'id': box.read(BoxName.passengerID) ?? AK.newId,
|
||||
'password': AK.passnpassenger,
|
||||
'aud': '${AK.allowed}$dev',
|
||||
},
|
||||
);
|
||||
if (response0.statusCode == 200) {
|
||||
final decodedResponse1 = jsonDecode(response0.body);
|
||||
|
||||
final jwt = decodedResponse1['jwt'];
|
||||
box.write(BoxName.jwt, X.c(X.c(X.c(jwt, cn), cC), cs));
|
||||
|
||||
await AppInitializer().getAIKey(Driver.keyOfApp);
|
||||
await AppInitializer().getAIKey(Driver.initializationVector);
|
||||
await Future.delayed(Duration.zero);
|
||||
await EncryptionHelper.initialize();
|
||||
|
||||
await AppInitializer().getAIKey(Driver.payMobApikey);
|
||||
await AppInitializer().getAIKey(Driver.FCM_PRIVATE_KEY);
|
||||
|
||||
await AppInitializer().getKey();
|
||||
} else {}
|
||||
} else {
|
||||
await EncryptionHelper.initialize();
|
||||
|
||||
var payload = {
|
||||
'id': box.read(BoxName.passengerID),
|
||||
'password': AK.passnpassenger,
|
||||
'aud': '${AK.allowed}$dev',
|
||||
};
|
||||
var response1 = await http.post(
|
||||
Uri.parse(AppLink.loginJwtDriver),
|
||||
body: payload,
|
||||
);
|
||||
|
||||
if (response1.statusCode == 200) {
|
||||
final decodedResponse1 = jsonDecode(response1.body);
|
||||
Log.print('decodedResponse1: ${decodedResponse1}');
|
||||
|
||||
final jwt = decodedResponse1['jwt'];
|
||||
await box.write(BoxName.jwt, X.c(X.c(X.c(jwt, cn), cC), cs));
|
||||
await AppInitializer().getKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getLocationPermission() async {
|
||||
Get.put(LocationBackgroundController()).requestLocationPermission();
|
||||
|
||||
@@ -119,7 +198,7 @@ class LoginDriverController extends GetxController {
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.loginFromGoogleCaptin, payload: {
|
||||
'email': email.toString().contains('@')
|
||||
? encryptionHelper.encryptData(email)
|
||||
? EncryptionHelper.instance.encryptData(email)
|
||||
: email,
|
||||
'id': driverID,
|
||||
});
|
||||
@@ -161,13 +240,13 @@ class LoginDriverController extends GetxController {
|
||||
(jsonDecoeded['data'][0]['accountBank']));
|
||||
box.write(
|
||||
BoxName.nameDriver,
|
||||
'${encryptionHelper.decryptData(jsonDecoeded['data'][0]['first_name'])}'
|
||||
' ${encryptionHelper.decryptData(jsonDecoeded['data'][0]['last_name'])}');
|
||||
'${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['first_name'])}'
|
||||
' ${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['last_name'])}');
|
||||
if (((jsonDecoeded['data'][0]['model'])
|
||||
.toString()
|
||||
.contains('دراجه') ||
|
||||
jsonDecoeded['data'][0]['make'].toString().contains('دراجه '))) {
|
||||
if (encryptionHelper
|
||||
if (EncryptionHelper.instance
|
||||
.decryptData(jsonDecoeded['data'][0]['gender'])
|
||||
.toString() ==
|
||||
'Male') {
|
||||
@@ -197,13 +276,14 @@ class LoginDriverController extends GetxController {
|
||||
payload: {'captain_id': (box.read(BoxName.driverID)).toString()});
|
||||
|
||||
if (token != 'failure') {
|
||||
if (encryptionHelper
|
||||
if (EncryptionHelper.instance
|
||||
.decryptData(jsonDecode(token)['data'][0]['token']) !=
|
||||
encryptionHelper.decryptData(box.read(BoxName.tokenDriver))) {
|
||||
EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.tokenDriver))) {
|
||||
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
|
||||
'token change'.tr,
|
||||
'change device'.tr,
|
||||
encryptionHelper
|
||||
EncryptionHelper.instance
|
||||
.decryptData(jsonDecode(token)['data'][0]['token'])
|
||||
.toString(),
|
||||
[],
|
||||
@@ -262,11 +342,11 @@ class LoginDriverController extends GetxController {
|
||||
update();
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.loginUsingCredentialsWithoutGoogle, payload: {
|
||||
'email': encryptionHelper.encryptData(email),
|
||||
'email': EncryptionHelper.instance.encryptData(email),
|
||||
'password': password,
|
||||
});
|
||||
box.write(
|
||||
BoxName.emailDriver, encryptionHelper.encryptData(email).toString());
|
||||
box.write(BoxName.emailDriver,
|
||||
EncryptionHelper.instance.encryptData(email).toString());
|
||||
print(res);
|
||||
if (res == 'failure') {
|
||||
//Failure
|
||||
@@ -292,7 +372,7 @@ class LoginDriverController extends GetxController {
|
||||
box.write(BoxName.phoneDriver, (jsonDecoeded['data'][0]['phone']));
|
||||
box.write(
|
||||
BoxName.nameArabic,
|
||||
encryptionHelper
|
||||
EncryptionHelper.instance
|
||||
.decryptData(jsonDecoeded['data'][0]['name_arabic']));
|
||||
box.write(
|
||||
BoxName.bankCodeDriver, (jsonDecoeded['data'][0]['bankCode']));
|
||||
@@ -300,11 +380,11 @@ class LoginDriverController extends GetxController {
|
||||
jsonDecoeded['data'][0]['accountBank']);
|
||||
box.write(
|
||||
BoxName.nameDriver,
|
||||
'${encryptionHelper.decryptData(jsonDecoeded['data'][0]['first_name'])}'
|
||||
' ${encryptionHelper.decryptData(jsonDecoeded['data'][0]['last_name'])}');
|
||||
'${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['first_name'])}'
|
||||
' ${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['last_name'])}');
|
||||
if ((jsonDecoeded['data'][0]['model'].toString().contains('دراجه') ||
|
||||
jsonDecoeded['data'][0]['make'].toString().contains('دراجه '))) {
|
||||
if (encryptionHelper
|
||||
if (EncryptionHelper.instance
|
||||
.decryptData(jsonDecoeded['data'][0]['gender'])
|
||||
.toString() ==
|
||||
'Male') {
|
||||
@@ -314,7 +394,7 @@ class LoginDriverController extends GetxController {
|
||||
}
|
||||
} else if (int.parse(jsonDecoeded['data'][0]['year'].toString()) >
|
||||
2017) {
|
||||
if (encryptionHelper
|
||||
if (EncryptionHelper.instance
|
||||
.decryptData(jsonDecoeded['data'][0]['gender'])
|
||||
.toString() !=
|
||||
'Male') {
|
||||
@@ -337,13 +417,14 @@ class LoginDriverController extends GetxController {
|
||||
payload: {'captain_id': box.read(BoxName.driverID).toString()});
|
||||
|
||||
if (token != 'failure') {
|
||||
if (encryptionHelper
|
||||
if (EncryptionHelper.instance
|
||||
.decryptData(jsonDecode(token)['data'][0]['token']) !=
|
||||
encryptionHelper.decryptData(box.read(BoxName.tokenDriver))) {
|
||||
EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.tokenDriver))) {
|
||||
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
|
||||
'token change'.tr,
|
||||
'change device'.tr,
|
||||
encryptionHelper
|
||||
EncryptionHelper.instance
|
||||
.decryptData(jsonDecode(token)['data'][0]['token'])
|
||||
.toString(),
|
||||
[],
|
||||
|
||||
@@ -108,8 +108,8 @@ class RegisterCaptainController extends GetxController {
|
||||
if (isValidEgyptianPhoneNumber(phoneController.text)) {
|
||||
var responseCheker = await CRUD()
|
||||
.post(link: AppLink.checkPhoneNumberISVerfiedDriver, payload: {
|
||||
'phone_number':
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'),
|
||||
'phone_number': EncryptionHelper.instance
|
||||
.encryptData('+2${phoneController.text}'),
|
||||
});
|
||||
if (responseCheker != 'failure') {
|
||||
var d = jsonDecode(responseCheker);
|
||||
@@ -117,18 +117,20 @@ class RegisterCaptainController extends GetxController {
|
||||
Get.snackbar('Phone number is verified before'.tr, '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
box.write(BoxName.phone,
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'));
|
||||
box.write(
|
||||
BoxName.phone,
|
||||
EncryptionHelper.instance
|
||||
.encryptData('+2${phoneController.text}'));
|
||||
await Get.put(LoginDriverController()).loginWithGoogleCredential(
|
||||
box.read(BoxName.driverID).toString(),
|
||||
box.read(BoxName.emailDriver).toString(),
|
||||
);
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number':
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'),
|
||||
'token_code':
|
||||
encryptionHelper.encryptData(randomNumber.toString()),
|
||||
'phone_number': EncryptionHelper.instance
|
||||
.encryptData('+2${phoneController.text}'),
|
||||
'token_code': EncryptionHelper.instance
|
||||
.encryptData(randomNumber.toString()),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": box.read(BoxName.emailDriver),
|
||||
});
|
||||
@@ -143,10 +145,10 @@ class RegisterCaptainController extends GetxController {
|
||||
}
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
|
||||
'phone_number':
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'),
|
||||
'token_code':
|
||||
encryptionHelper.encryptData(randomNumber.toString()),
|
||||
'phone_number': EncryptionHelper.instance
|
||||
.encryptData('+2${phoneController.text}'),
|
||||
'token_code': EncryptionHelper.instance
|
||||
.encryptData(randomNumber.toString()),
|
||||
"driverId": box.read(BoxName.driverID),
|
||||
"email": box.read(BoxName.emailDriver),
|
||||
});
|
||||
@@ -247,7 +249,7 @@ class RegisterCaptainController extends GetxController {
|
||||
mySnackbarSuccess('Phone number is already verified'.tr);
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
box.write(BoxName.phone,
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'));
|
||||
EncryptionHelper.instance.encryptData('+2${phoneController.text}'));
|
||||
Get.put(LoginDriverController()).loginWithGoogleCredential(
|
||||
box.read(BoxName.driverID).toString(),
|
||||
box.read(BoxName.emailDriver).toString(),
|
||||
@@ -262,8 +264,9 @@ class RegisterCaptainController extends GetxController {
|
||||
await CRUD().post(
|
||||
link: AppLink.sendVerifyOtpMessage,
|
||||
payload: {
|
||||
'phone_number': encryptionHelper.encryptData('+2$phoneNumber'),
|
||||
'token_code': encryptionHelper.encryptData(randomNumber.toString()),
|
||||
'phone_number': EncryptionHelper.instance.encryptData('+2$phoneNumber'),
|
||||
'token_code':
|
||||
EncryptionHelper.instance.encryptData(randomNumber.toString()),
|
||||
'driverId': box.read(BoxName.driverID),
|
||||
'email': box.read(BoxName.emailDriver),
|
||||
},
|
||||
@@ -282,13 +285,14 @@ class RegisterCaptainController extends GetxController {
|
||||
if (formKey3.currentState!.validate()) {
|
||||
var res = await CRUD().post(link: AppLink.verifyOtpDriver, payload: {
|
||||
'phone_number':
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'),
|
||||
'token_code': encryptionHelper.encryptData(verifyCode.text.toString()),
|
||||
EncryptionHelper.instance.encryptData('+2${phoneController.text}'),
|
||||
'token_code':
|
||||
EncryptionHelper.instance.encryptData(verifyCode.text.toString()),
|
||||
});
|
||||
if (res != 'failure') {
|
||||
// var dec = jsonDecode(res);
|
||||
box.write(BoxName.phoneDriver,
|
||||
encryptionHelper.encryptData('+2${phoneController.text}'));
|
||||
EncryptionHelper.instance.encryptData('+2${phoneController.text}'));
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
|
||||
// loginDriverController.isGoogleLogin == true
|
||||
@@ -313,10 +317,10 @@ class RegisterCaptainController extends GetxController {
|
||||
sendVerifications() async {
|
||||
var res = await CRUD().post(link: AppLink.verifyEmail, payload: {
|
||||
'email': emailController.text.isEmpty
|
||||
? encryptionHelper.encryptData(
|
||||
? EncryptionHelper.instance.encryptData(
|
||||
Get.find<LoginDriverController>().emailController.text.toString())
|
||||
: encryptionHelper.encryptData(emailController.text),
|
||||
'token': encryptionHelper.encryptData(verifyCode.text),
|
||||
: EncryptionHelper.instance.encryptData(emailController.text),
|
||||
'token': EncryptionHelper.instance.encryptData(verifyCode.text),
|
||||
});
|
||||
|
||||
if (res != 'failure') {
|
||||
|
||||
@@ -126,7 +126,7 @@ class GoogleSignInHelper {
|
||||
box.write(BoxName.driverID,
|
||||
(user.id) ?? 'Unknown ID'); // Ensure there's a fallback value
|
||||
box.write(BoxName.emailDriver,
|
||||
encryptionHelper.encryptData(user.email) ?? 'Unknown Email');
|
||||
EncryptionHelper.instance.encryptData(user.email) ?? 'Unknown Email');
|
||||
}
|
||||
|
||||
// Method to handle Google Sign-Out
|
||||
|
||||
Reference in New Issue
Block a user