Update: 2026-06-26 01:43:37
This commit is contained in:
@@ -10,6 +10,7 @@ import '../constant/box_name.dart';
|
||||
import '../main.dart';
|
||||
import '../print.dart';
|
||||
import '../views/home/main.dart';
|
||||
import '../views/widgets/mycircular.dart';
|
||||
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
@@ -67,14 +68,11 @@ class LoginController extends GetxController {
|
||||
if (otpSent) {
|
||||
_showOtpDialog(phone, pass, fingerprint, d);
|
||||
} else {
|
||||
Get.snackbar('Error', 'Failed to send OTP'.tr);
|
||||
mySnackbarError('Failed to send OTP'.tr);
|
||||
}
|
||||
} else {
|
||||
Get.snackbar(
|
||||
'خطأ'.tr,
|
||||
mySnackbarError(
|
||||
res is Map ? res['message'].toString().tr : 'فشل تسجيل الدخول'.tr,
|
||||
backgroundColor: Colors.red.withOpacity(0.7),
|
||||
colorText: Colors.white,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -120,7 +118,7 @@ class LoginController extends GetxController {
|
||||
Get.back(); // close dialog
|
||||
await _verifyOtpAndFinalize(phone, otpCode, pass, loginData);
|
||||
} else {
|
||||
Get.snackbar('خطأ', 'الرجاء إدخال رمز صحيح'.tr);
|
||||
mySnackbarError('الرجاء إدخال رمز صحيح'.tr);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -161,12 +159,12 @@ class LoginController extends GetxController {
|
||||
|
||||
Get.offAll(() => Main());
|
||||
} else {
|
||||
Get.snackbar('Error', 'Invalid OTP'.tr);
|
||||
mySnackbarError('Invalid OTP'.tr);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.back();
|
||||
Log.print('OTP VERIFY ERROR: $e');
|
||||
Get.snackbar('Error', e.toString());
|
||||
mySnackbarError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +173,17 @@ class LoginController extends GetxController {
|
||||
await EncryptionHelper.initialize();
|
||||
await DeviceHelper.getDeviceFingerprint();
|
||||
|
||||
// If stored JWT is still valid, skip login and go straight to Main
|
||||
String? storedJwt = await storage.read(key: BoxName.jwt);
|
||||
if (storedJwt != null && CRUD.isJwtValid(r(storedJwt))) {
|
||||
String? storedPass = await storage.read(key: 'password');
|
||||
if (storedPass != null) {
|
||||
await box.write(BoxName.password, storedPass);
|
||||
}
|
||||
Get.offAll(() => Main());
|
||||
return;
|
||||
}
|
||||
|
||||
// Auto login if credentials exist
|
||||
String? storedPassword = await storage.read(key: 'password');
|
||||
if (storedPassword != null) {
|
||||
|
||||
Reference in New Issue
Block a user