Login with face and finger fixed

faiz_marathon_signalR_critical
devmirza121 2 years ago
parent e0088a515b
commit 8ce3a09375

@ -11,6 +11,7 @@
"lastLoginDetails": "تفاصيل تسجيل الدخول الأخير:",
"verificationType": "نوع التحقق:",
"pleaseVerify": "ارجوك تحقق",
"pleaseVerifyForBio": "الرجاء التحقق من تسجيل الدخول باستخدام أحد هذه الخيارات",
"verifyThroughFace": "تحقق من خلال الوجه",
"verifyThroughFingerprint": "تحقق من خلال بصمة الإصبع",
"verifyThroughSMS": "تحقق من خلال الرسائل القصيرة",

@ -11,6 +11,7 @@
"lastLoginDetails": "Last Login Details:",
"verificationType": "Verification Type:",
"pleaseVerify": "Please Verify",
"pleaseVerifyForBio": "Please verify login with one of the following options",
"verifyThroughFace": "Verify Through Face",
"verifyThroughFingerprint": "Verify Through Fingerprint",
"verifyThroughSMS": "Verify Through SMS",

@ -23,7 +23,7 @@ class LoginApiClient {
postParams["DeviceType"] = deviceType;
return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
return (responseData.mohemmGetMobileLoginInfoList?.length ?? 0) > 0 ? responseData.mohemmGetMobileLoginInfoList!.first : null;
return (responseData.mohemmGetMobileLoginInfoList?.length ?? 0) > 0 ? (responseData.mohemmGetMobileLoginInfoList!.first) : null;
}, url, postParams);
}

@ -87,7 +87,7 @@ class OtpDialog {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SvgPicture.asset(
type == 1 ? "assets/images/login/verify_sms.svg" : "assets/images/login/verify_whatsapp.svg",
type == 1 ? "assets/images/login/verify_sms.svg" :type==2? "assets/images/login/verify_thumb.svg":type==3? "assets/images/login/verify_face.svg":'assets/images/login/verify_whatsapp.svg',
height: 50,
width: 50,
),

@ -13,6 +13,7 @@ abstract class LocaleKeys {
static const lastLoginDetails = 'lastLoginDetails';
static const verificationType = 'verificationType';
static const pleaseVerify = 'pleaseVerify';
static const pleaseVerifyForBio = 'pleaseVerifyForBio';
static const verifyThroughFace = 'verifyThroughFace';
static const verifyThroughFingerprint = 'verifyThroughFingerprint';
static const verifyThroughSMS = 'verifyThroughSMS';

@ -22,6 +22,11 @@ import 'package:mohem_flutter_app/models/generic_response_model.dart';
import 'package:mohem_flutter_app/models/get_mobile_login_info_list_model.dart';
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
// WhatsApp 4
// SMS 1
// Face ID 3
// Finger Print 2
class VerifyLastLoginScreen extends StatefulWidget {
VerifyLastLoginScreen({Key? key}) : super(key: key);
@ -36,6 +41,10 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
List<BiometricType> _availableBioMetricType = [];
GetMobileLoginInfoListModel? mobileLoginInfoListModel;
//For face and finger print verification
int selectedFlag = 0;
bool isNeedVerifyWithFaceIDAndBiometrics = false;
@override
void initState() {
_getAvailableBiometrics();
@ -47,6 +56,7 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
Widget build(BuildContext context) {
mobileLoginInfoListModel ??= ModalRoute.of(context)!.settings.arguments as GetMobileLoginInfoListModel;
String empName = AppState().isArabic(context) ? AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEAr! : AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEEn!;
print("selectedFlag1: " + mobileLoginInfoListModel!.loginType.toString());
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
@ -110,15 +120,16 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
),
),
LocaleKeys.pleaseVerify.tr().toText16(),
if (isNeedVerifyWithFaceIDAndBiometrics) LocaleKeys.pleaseVerifyForBio.tr().toText12(),
GridView(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9),
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.only(top: 9),
shrinkWrap: true,
children: [
getButton(3),
if (!isNeedVerifyWithFaceIDAndBiometrics) getButton(3),
if (!isNeedVerifyWithFaceIDAndBiometrics) getButton(2),
getButton(4),
getButton(2),
getButton(1),
],
)
@ -164,7 +175,7 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
DefaultButton(
LocaleKeys.useAnotherAccount.tr(),
() {
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.login, (Route<dynamic> route) => false,arguments: false);
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.login, (Route<dynamic> route) => false, arguments: false);
},
).insideContainer,
],
@ -221,62 +232,32 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
// isMoreOption = true;
});
} else {
try {
Utils.showLoading(context);
if (_flag == 4 || _flag == 3) {
bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
if (authenticateWithFaceAndTouchID) {
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route<dynamic> route) => false);
return;
if (_flag == 2 || _flag == 3) {
bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
if (!authenticateWithFaceAndTouchID) {
return;
} else {
if (mobileLoginInfoListModel!.loginType == 2 || mobileLoginInfoListModel!.loginType == 3) {
bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
if (!authenticateWithFaceAndTouchID) {
return;
} else {
performApiCall(_title, _icon, _flag, isDirectLogin: true);
}
} else {
Utils.hideLoading(context);
return;
isNeedVerifyWithFaceIDAndBiometrics = true;
selectedFlag = _flag;
setState(() {
return;
});
}
}
await LoginApiClient().checkMobileAppVersion();
await LoginApiClient().memberLogin(AppState().getUserName!, AppState().password!);
BasicMemberInformationModel? memberInformationModel = await LoginApiClient().mohemmSendActivationCodeByOTPNotificationType(
checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName);
Utils.hideLoading(context);
OtpDialog(
context,
_flag,
int.tryParse(AppState().memberLoginList?.pMOBILENUMBER ?? ""),
(value) async {
Utils.showLoading(context);
try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(false, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0,
genericResponseModel?.memberInformationList![0].eMPLOYEENAME ?? "",
_flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!,
mobileLoginInfoListModel!.deviceToken!,
Platform.isAndroid ? "android" : "ios");
if (genericResponseModel?.errorMessage != null) {
Utils.showToast(genericResponseModel?.errorMessage ?? "");
// Navigator.pop(context);
}
Utils.hideLoading(context);
Navigator.pop(context);
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route<dynamic> route) => false);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
},
() => {
Navigator.pop(context),
},
).displayDialog(context);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
} else {
if (isNeedVerifyWithFaceIDAndBiometrics)
performApiCall(_title, _icon, selectedFlag);
else
performApiCall(_title, _icon, _flag);
}
// authenticateUser(_flag, isActive: _loginIndex);
}
},
child: Container(
@ -305,14 +286,14 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
Widget getButton(int flag) {
switch (flag) {
case 2:
return _loginOptionButton(LocaleKeys.verifyThroughWhatsapp.tr(), 'assets/images/login/verify_whatsapp.svg', flag, null);
case 1:
return _loginOptionButton(LocaleKeys.verifyThroughSMS.tr(), 'assets/images/login/verify_sms.svg', flag, null);
case 4:
case 2:
return _loginOptionButton(LocaleKeys.verifyThroughFingerprint.tr(), 'assets/images/login/verify_thumb.svg', flag, BiometricType.fingerprint.index);
case 3:
return _loginOptionButton(LocaleKeys.verifyThroughFace.tr(), 'assets/images/login/verify_face.svg', flag, BiometricType.face.index);
case 4:
return _loginOptionButton(LocaleKeys.verifyThroughWhatsapp.tr(), 'assets/images/login/verify_whatsapp.svg', flag, null);
default:
return const SizedBox();
}
@ -328,6 +309,66 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
}
return isAvailable;
}
Future<void> performApiCall(String _title, String _icon, int _flag, {bool isDirectLogin = false}) async {
try {
if (isDirectLogin)
setState(() {
Utils.showLoading(context);
});
else
Utils.showLoading(context);
await LoginApiClient().checkMobileAppVersion();
await LoginApiClient().memberLogin(AppState().getUserName!, AppState().password!);
if (!isDirectLogin)
BasicMemberInformationModel? memberInformationModel = await LoginApiClient()
.mohemmSendActivationCodeByOTPNotificationType(checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName);
if (isDirectLogin) performDirectApiCall(_title, _icon, _flag, "");
if (!isDirectLogin) Utils.hideLoading(context);
if (!isDirectLogin)
OtpDialog(
context,
_flag,
int.tryParse(AppState().memberLoginList?.pMOBILENUMBER ?? ""),
(value) async {
Utils.showLoading(context);
performDirectApiCall(_title, _icon, _flag, value);
},
() => {
Navigator.pop(context),
},
).displayDialog(context);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
Future<void> performDirectApiCall(String _title, String _icon, int _flag, String value, {bool isDirectLogin = false}) async {
try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(false, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0,
genericResponseModel?.memberInformationList![0].eMPLOYEENAME ?? "",
_flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!,
mobileLoginInfoListModel!.deviceToken!,
Platform.isAndroid ? "android" : "ios");
if (genericResponseModel?.errorMessage != null) {
Utils.showToast(genericResponseModel?.errorMessage ?? "");
// Navigator.pop(context);
}
Utils.hideLoading(context);
Navigator.pop(context);
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route<dynamic> route) => false);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
//
// formatDate(date) {
// return date;

@ -13,6 +13,7 @@ import 'package:mohem_flutter_app/classes/consts.dart';
import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/dialogs/otp_dialog.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/models/basic_member_information_model.dart';
@ -20,6 +21,11 @@ import 'package:mohem_flutter_app/models/generic_response_model.dart';
import 'package:mohem_flutter_app/models/member_information_list_model.dart';
import 'package:mohem_flutter_app/models/privilege_list_model.dart';
// WhatsApp 4
// SMS 1
// Face ID 3
// Finger Print 2
class VerifyLoginScreen extends StatefulWidget {
VerifyLoginScreen({Key? key}) : super(key: key);
@ -35,6 +41,10 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
String? firebaseToken;
//For face and finger print verification
int selectedFlag = 0;
bool isNeedVerifyWithFaceIDAndBiometrics = false;
@override
void initState() {
_getAvailableBiometrics();
@ -59,15 +69,16 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
physics: const BouncingScrollPhysics(),
children: [
LocaleKeys.pleaseVerify.tr().toText16(),
if (isNeedVerifyWithFaceIDAndBiometrics) LocaleKeys.pleaseVerifyForBio.tr().toText12(),
GridView(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9),
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.only(top: 9),
shrinkWrap: true,
children: [
getButton(3),
if (!isNeedVerifyWithFaceIDAndBiometrics) getButton(3),
if (!isNeedVerifyWithFaceIDAndBiometrics) getButton(2),
getButton(4),
getButton(2),
getButton(1),
],
)
@ -500,6 +511,7 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
// }
//
Future<bool> loginWithFaceIDAndBiometrics() async {
IOSAuthMessages iosStrings =
const IOSAuthMessages(cancelButton: 'cancel', goToSettingsButton: 'settings', goToSettingsDescription: 'Please set up your Touch ID.', lockOut: 'Please reenable your Touch ID');
@ -525,69 +537,22 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
// isMoreOption = true;
});
} else {
try {
Utils.showLoading(context);
if (_flag == 4 || _flag == 3) {
bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
if (!authenticateWithFaceAndTouchID) {
if (_flag == 2 || _flag == 3) {
bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
if (!authenticateWithFaceAndTouchID) {
return;
} else {
isNeedVerifyWithFaceIDAndBiometrics = true;
selectedFlag = _flag;
setState(() {
return;
}
});
}
await LoginApiClient().checkMobileAppVersion();
await LoginApiClient().memberLogin(AppState().getUserName!, AppState().password!);
BasicMemberInformationModel? memberInformationModel = await LoginApiClient().mohemmSendActivationCodeByOTPNotificationType(
checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName);
Utils.hideLoading(context);
OtpDialog(
context,
_flag,
int.tryParse(AppState().memberLoginList?.pMOBILENUMBER ?? ""),
(value) async {
Utils.showLoading(context);
try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0,
genericResponseModel?.memberInformationList![0].eMPLOYEENAME ?? "",
_flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!,
firebaseToken!,
Platform.isAndroid ? "android" : "ios");
if (genericResponseModel?.errorMessage != null) {
Utils.showToast(genericResponseModel?.errorMessage ?? "");
} else {
AppState().setPrivilegeListModel = genericResponseModel!.privilegeList ?? [];
AppState().setMemberInformationListModel = genericResponseModel.memberInformationList?.first;
MemberInformationListModel.saveToPrefs(genericResponseModel.memberInformationList ?? []);
genericResponseModel.privilegeList!.forEach((element) {
print(element.serviceName.toString() + " " + element.previlege.toString()); // Check availability
});
PrivilegeListModel.saveToPrefs(genericResponseModel.privilegeList ?? []);
AppState().setMohemmWifiSSID = genericResponseModel.mohemmWifiSSID;
AppState().setMohemmWifiPassword = genericResponseModel.mohemmWifiPassword;
Utils.saveStringFromPrefs(SharedPrefsConsts.username, AppState().getUserName!);
Utils.saveStringFromPrefs(SharedPrefsConsts.password, AppState().password!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID, genericResponseModel.mohemmWifiSSID!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiPassword, genericResponseModel.mohemmWifiPassword!);
}
Utils.hideLoading(context);
Navigator.pop(context);
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route<dynamic> route) => false);
} catch (ex) {
print(ex);
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
},
() => {
Navigator.pop(context),
},
).displayDialog(context);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
} else {
if (isNeedVerifyWithFaceIDAndBiometrics)
performApiCall(_title, _icon, selectedFlag);
else
performApiCall(_title, _icon, _flag);
}
}
},
@ -617,14 +582,14 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
Widget getButton(int flag) {
switch (flag) {
case 2:
return _loginOptionButton(LocaleKeys.verifyThroughWhatsapp.tr(), 'assets/images/login/verify_whatsapp.svg', flag, null);
case 1:
return _loginOptionButton(LocaleKeys.verifyThroughSMS.tr(), 'assets/images/login/verify_sms.svg', flag, null);
case 4:
case 2:
return _loginOptionButton(LocaleKeys.verifyThroughFingerprint.tr(), 'assets/images/login/verify_thumb.svg', flag, BiometricType.fingerprint.index);
case 3:
return _loginOptionButton(LocaleKeys.verifyThroughFace.tr(), 'assets/images/login/verify_face.svg', flag, BiometricType.face.index);
case 4:
return _loginOptionButton(LocaleKeys.verifyThroughWhatsapp.tr(), 'assets/images/login/verify_whatsapp.svg', flag, null);
default:
return const SizedBox();
}
@ -640,6 +605,67 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
}
return isAvailable;
}
Future<void> performApiCall(String _title, String _icon, int _flag) async {
try {
Utils.showLoading(context);
await LoginApiClient().checkMobileAppVersion();
await LoginApiClient().memberLogin(AppState().getUserName!, AppState().password!);
BasicMemberInformationModel? memberInformationModel = await LoginApiClient()
.mohemmSendActivationCodeByOTPNotificationType(checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName);
Utils.hideLoading(context);
OtpDialog(
context,
_flag,
int.tryParse(AppState().memberLoginList?.pMOBILENUMBER ?? ""),
(value) async {
Utils.showLoading(context);
try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0,
genericResponseModel?.memberInformationList![0].eMPLOYEENAME ?? "",
_flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!,
firebaseToken!,
Platform.isAndroid ? "android" : "ios");
if (genericResponseModel?.errorMessage != null) {
Utils.showToast(genericResponseModel?.errorMessage ?? "");
} else {
AppState().setPrivilegeListModel = genericResponseModel!.privilegeList ?? [];
AppState().setMemberInformationListModel = genericResponseModel.memberInformationList?.first;
MemberInformationListModel.saveToPrefs(genericResponseModel.memberInformationList ?? []);
genericResponseModel.privilegeList!.forEach((element) {
print(element.serviceName.toString() + " " + element.previlege.toString()); // Check availability
});
PrivilegeListModel.saveToPrefs(genericResponseModel.privilegeList ?? []);
AppState().setMohemmWifiSSID = genericResponseModel.mohemmWifiSSID;
AppState().setMohemmWifiPassword = genericResponseModel.mohemmWifiPassword;
Utils.saveStringFromPrefs(SharedPrefsConsts.username, AppState().getUserName!);
Utils.saveStringFromPrefs(SharedPrefsConsts.password, AppState().password!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID, genericResponseModel.mohemmWifiSSID!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiPassword, genericResponseModel.mohemmWifiPassword!);
}
Utils.hideLoading(context);
Navigator.pop(context);
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route<dynamic> route) => false);
} catch (ex) {
print(ex);
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
},
() => {
Navigator.pop(context),
},
).displayDialog(context);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
//
// formatDate(date) {
// return date;

Loading…
Cancel
Save