Update: 2026-06-26 02:00:23
This commit is contained in:
@@ -62,13 +62,17 @@ class LoginController extends GetxController {
|
||||
await storage.write(key: 'email', value: emailStr);
|
||||
await box.write(BoxName.email, emailStr);
|
||||
|
||||
// Request OTP from unified module
|
||||
String phone = d['data']['phone'] ?? '';
|
||||
bool otpSent = await _sendOtp(phone);
|
||||
if (otpSent) {
|
||||
_showOtpDialog(phone, pass, fingerprint, d);
|
||||
bool otpRequired = d['otp_required'] ?? true;
|
||||
if (otpRequired) {
|
||||
String phone = d['data']['phone'] ?? '';
|
||||
bool otpSent = await _sendOtp(phone);
|
||||
if (otpSent) {
|
||||
_showOtpDialog(phone, pass, fingerprint, d);
|
||||
} else {
|
||||
mySnackbarError('Failed to send OTP'.tr);
|
||||
}
|
||||
} else {
|
||||
mySnackbarError('Failed to send OTP'.tr);
|
||||
await _finalizeLogin(pass, d);
|
||||
}
|
||||
} else {
|
||||
mySnackbarError(
|
||||
@@ -138,26 +142,7 @@ class LoginController extends GetxController {
|
||||
Get.back(); // close loading
|
||||
|
||||
if (response != 'failure' && response['status'] == 'success') {
|
||||
// Finalize login
|
||||
final jwt = loginData['jwt'];
|
||||
final hmac = loginData['hmac'];
|
||||
await box.write(BoxName.jwt, c(jwt));
|
||||
await storage.write(key: BoxName.jwt, value: c(jwt));
|
||||
if (hmac != null) {
|
||||
await box.write(BoxName.hmac, hmac);
|
||||
}
|
||||
|
||||
var userData = loginData['data'];
|
||||
await storage.write(key: 'name', value: userData['first_name']);
|
||||
await storage.write(key: 'driverID', value: userData['id'].toString());
|
||||
await storage.write(key: 'password', value: pass);
|
||||
await box.write(BoxName.employeename, userData['first_name']);
|
||||
await box.write(BoxName.password, pass);
|
||||
if (userData['country'] != null) {
|
||||
await box.write(BoxName.countryCode, userData['country']);
|
||||
}
|
||||
|
||||
Get.offAll(() => Main());
|
||||
await _finalizeLogin(pass, loginData);
|
||||
} else {
|
||||
mySnackbarError('Invalid OTP'.tr);
|
||||
}
|
||||
@@ -168,6 +153,28 @@ class LoginController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _finalizeLogin(String pass, dynamic loginData) async {
|
||||
final jwt = loginData['jwt'];
|
||||
final hmac = loginData['hmac'];
|
||||
await box.write(BoxName.jwt, c(jwt));
|
||||
await storage.write(key: BoxName.jwt, value: c(jwt));
|
||||
if (hmac != null) {
|
||||
await box.write(BoxName.hmac, hmac);
|
||||
}
|
||||
|
||||
var userData = loginData['data'];
|
||||
await storage.write(key: 'name', value: userData['first_name']);
|
||||
await storage.write(key: 'driverID', value: userData['id'].toString());
|
||||
await storage.write(key: 'password', value: pass);
|
||||
await box.write(BoxName.employeename, userData['first_name']);
|
||||
await box.write(BoxName.password, pass);
|
||||
if (userData['country'] != null) {
|
||||
await box.write(BoxName.countryCode, userData['country']);
|
||||
}
|
||||
|
||||
Get.offAll(() => Main());
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
await EncryptionHelper.initialize();
|
||||
|
||||
Reference in New Issue
Block a user