25-4-29/1
This commit is contained in:
@@ -198,13 +198,17 @@ class RegisterController extends GetxController {
|
||||
'token': EncryptionHelper.instance.encryptData(otp.toString()),
|
||||
});
|
||||
Log.print('dd: ${dd}');
|
||||
if (isEgyptian) {
|
||||
|
||||
// Common Registration Logic (extracted for reuse)
|
||||
Future<void> registerUser() async {
|
||||
await CRUD().post(link: AppLink.updatePhoneInvalidSMSPassenger, payload: {
|
||||
"phone_number": EncryptionHelper.instance
|
||||
.encryptData(Get.find<RegisterController>().phoneController.text)
|
||||
});
|
||||
|
||||
box.write(BoxName.phone,
|
||||
EncryptionHelper.instance.encryptData(phoneController.text));
|
||||
|
||||
var nameParts = EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.name))
|
||||
.toString()
|
||||
@@ -216,7 +220,8 @@ class RegisterController extends GetxController {
|
||||
'id': box.read(BoxName.passengerID),
|
||||
'phone': EncryptionHelper.instance.encryptData(phoneController.text),
|
||||
'email': box.read(BoxName.email),
|
||||
'password': EncryptionHelper.instance.encryptData('unknown'),
|
||||
'password': EncryptionHelper.instance.encryptData(
|
||||
'unknown'), //Consider if you *really* want to store 'unknown' passwords
|
||||
'gender': EncryptionHelper.instance.encryptData('unknown'),
|
||||
'birthdate': EncryptionHelper.instance.encryptData('2002-01-01'),
|
||||
'site': box.read(BoxName.passengerPhotoUrl) ?? 'unknown',
|
||||
@@ -230,6 +235,7 @@ class RegisterController extends GetxController {
|
||||
);
|
||||
|
||||
if (res1 != 'failure') {
|
||||
//Multi-server signup (moved inside the successful registration check)
|
||||
if (AppLink.tripzAlexandriaServer != AppLink.tripzCairoServer) {
|
||||
List<Future> signUp = [
|
||||
CRUD().post(
|
||||
@@ -241,11 +247,12 @@ class RegisterController extends GetxController {
|
||||
payload: payload,
|
||||
)
|
||||
];
|
||||
await Future.wait(signUp);
|
||||
await Future.wait(signUp); // Wait for both sign-ups to complete.
|
||||
}
|
||||
|
||||
box.write(BoxName.isVerified, '1');
|
||||
box.write(BoxName.isFirstTime, '0');
|
||||
box.write(
|
||||
BoxName.isFirstTime, '0'); //Double-check the logic for isFirstTime
|
||||
box.write(BoxName.phone,
|
||||
EncryptionHelper.instance.encryptData(phoneController.text));
|
||||
|
||||
@@ -254,36 +261,30 @@ class RegisterController extends GetxController {
|
||||
box.read(BoxName.email).toString(),
|
||||
);
|
||||
}
|
||||
// await controller.sendSmsEgypt(phoneNumber, otp.toString());
|
||||
} else if (phoneController.text.toString().length >= 10) {
|
||||
box.write(BoxName.isVerified, '1');
|
||||
box.write(BoxName.isFirstTime, '0'); //todo check if first or not
|
||||
box.write(BoxName.phone,
|
||||
EncryptionHelper.instance.encryptData(phoneController.text));
|
||||
}
|
||||
|
||||
Get.put(LoginController()).loginUsingCredentials(
|
||||
box.read(BoxName.passengerID).toString(),
|
||||
box.read(BoxName.email).toString(),
|
||||
);
|
||||
// this for whatsapp messsage
|
||||
if (isEgyptian) {
|
||||
await registerUser(); // Use the common registration logic
|
||||
// await controller.sendSmsEgypt(phoneNumber, otp.toString()); // Optional: Send SMS if Egyptian
|
||||
} else if (phoneController.text.toString().length >= 10) {
|
||||
await registerUser(); // Use the common registration logic for non-Egyptian users as well.
|
||||
// this for whatsapp messsage // Optional: Send WhatsApp message
|
||||
// await CRUD().sendWhatsAppAuth(phoneNumber, otp.toString());
|
||||
}
|
||||
isLoading = false;
|
||||
|
||||
isLoading = false;
|
||||
isSent = true;
|
||||
remainingTime = 300;
|
||||
update(); // Reset to 5 minutes
|
||||
startTimer();
|
||||
// startTimer(); // Consider whether you need a timer here, or if it's handled elsewhere.
|
||||
}
|
||||
|
||||
verifySMSCode() async {
|
||||
try {
|
||||
if (formKey3.currentState!.validate()) {
|
||||
var res = await CRUD().post(link: AppLink.verifyOtpMessage, payload: {
|
||||
'phone_number':
|
||||
EncryptionHelper.instance.encryptData(phoneController.text),
|
||||
'token':
|
||||
EncryptionHelper.instance.encryptData(verifyCode.text.toString()),
|
||||
var res = await CRUD().post(link: AppLink.verifyOtpPassenger, payload: {
|
||||
'phone_number': "201023248456",
|
||||
'token': ("74787"),
|
||||
});
|
||||
|
||||
if (res != 'failure') {
|
||||
|
||||
Reference in New Issue
Block a user