|
|
|
@ -63,6 +63,10 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
|
|
|
|
|
bool authenticated;
|
|
|
|
|
|
|
|
|
|
var fingrePrintBefore;
|
|
|
|
|
|
|
|
|
|
var selectedOption;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
@ -105,7 +109,9 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
helpers.showErrorToast('Error: ${snapshot.error}');
|
|
|
|
|
return Text('Error: ${snapshot.error}');
|
|
|
|
|
} else {
|
|
|
|
|
return Container(
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
|
height: SizeConfig.realScreenHeight,
|
|
|
|
|
width: SizeConfig.realScreenWidth,
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
@ -155,18 +161,17 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
// user. != null
|
|
|
|
|
// ? formatDate(Helpers
|
|
|
|
|
// .convertStringToDate(
|
|
|
|
|
// user
|
|
|
|
|
// .))
|
|
|
|
|
// : user !=
|
|
|
|
|
// null
|
|
|
|
|
// ? formatDate(Helpers
|
|
|
|
|
// .convertStringToDate(user
|
|
|
|
|
// .createdOn))
|
|
|
|
|
//:
|
|
|
|
|
'--',
|
|
|
|
|
user.editedOn != null
|
|
|
|
|
? formatDate(Helpers
|
|
|
|
|
.convertStringToDate(
|
|
|
|
|
user
|
|
|
|
|
.editedOn))
|
|
|
|
|
: user.createdOn !=
|
|
|
|
|
null
|
|
|
|
|
? formatDate(Helpers
|
|
|
|
|
.convertStringToDate(user
|
|
|
|
|
.createdOn))
|
|
|
|
|
: '--',
|
|
|
|
|
overflow:
|
|
|
|
|
TextOverflow.ellipsis,
|
|
|
|
|
textAlign:
|
|
|
|
@ -263,7 +268,7 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
3, authProv)),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: getButton(
|
|
|
|
|
2, authProv))
|
|
|
|
|
4, authProv))
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: SizedBox(),
|
|
|
|
@ -275,7 +280,7 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
child:
|
|
|
|
|
getButton(1, authProv)),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: getButton(4, authProv))
|
|
|
|
|
child: getButton(2, authProv))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
]),
|
|
|
|
@ -307,7 +312,7 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -342,14 +347,13 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
authProv
|
|
|
|
|
.sendActivationCodeForDoctorApp(activationCodeModel)
|
|
|
|
|
.then((res) {
|
|
|
|
|
widget.changeLoadingStata(false);
|
|
|
|
|
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
print("VerificationCode : " + res["VerificationCode"]);
|
|
|
|
|
sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]);
|
|
|
|
|
sharedPref.setString(
|
|
|
|
|
VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]);
|
|
|
|
|
sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]);
|
|
|
|
|
sharedPref.setString(PASSWORD, widget.password);
|
|
|
|
|
this.startSMSService(oTPSendType, authProv);
|
|
|
|
|
} else {
|
|
|
|
|
print(res['ErrorEndUserMessage']);
|
|
|
|
@ -380,9 +384,10 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
sendActivationCodeVerificationScreen(
|
|
|
|
|
oTPSendType, AuthViewModel authProv) async {
|
|
|
|
|
// TODO : build enum for verfication method
|
|
|
|
|
if (oTPSendType == 1 || oTPSendType == 2) {
|
|
|
|
|
//if (oTPSendType == 1 || oTPSendType == 2) {
|
|
|
|
|
widget.changeLoadingStata(true);
|
|
|
|
|
ActivationCodeModel2 activationCodeModel = ActivationCodeModel2(
|
|
|
|
|
iMEI: user.iMEI,
|
|
|
|
|
facilityId: user.projectID,
|
|
|
|
|
memberID: user.doctorID,
|
|
|
|
|
zipCode: user.outSA == true ? '971' : '966',
|
|
|
|
@ -396,15 +401,18 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
authProv
|
|
|
|
|
.sendActivationCodeVerificationScreen(activationCodeModel)
|
|
|
|
|
.then((res) {
|
|
|
|
|
widget.changeLoadingStata(false);
|
|
|
|
|
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
print("VerificationCode : " + res["VerificationCode"]);
|
|
|
|
|
sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]);
|
|
|
|
|
sharedPref.setString(
|
|
|
|
|
VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]);
|
|
|
|
|
sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]);
|
|
|
|
|
if (oTPSendType == 1 || oTPSendType == 2) {
|
|
|
|
|
widget.changeLoadingStata(false);
|
|
|
|
|
this.startSMSService(oTPSendType, authProv);
|
|
|
|
|
} else {
|
|
|
|
|
checkActivationCode(authProv);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
print(res['ErrorEndUserMessage']);
|
|
|
|
|
helpers.showErrorToast(res['ErrorEndUserMessage']);
|
|
|
|
@ -416,19 +424,10 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
helpers.showErrorToast();
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
} else {
|
|
|
|
|
// TODO route to this page with parameters to inicate we should present 2 option
|
|
|
|
|
if (Platform.isAndroid && oTPSendType == 3) {
|
|
|
|
|
helpers.showErrorToast('Your device not support this feature');
|
|
|
|
|
} else {
|
|
|
|
|
// Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
// builder: (BuildContext context) =>
|
|
|
|
|
// VerificationMethodsScreen(password: widget.password,)));
|
|
|
|
|
|
|
|
|
|
// Navigator.of(context).pushNamed(VERIFICATION_METHODS,
|
|
|
|
|
// arguments: {'verificationMethod': oTPSendType});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// checkActivationCode(authProv);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget getButton(flag, authProv) {
|
|
|
|
@ -635,10 +634,10 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
|
|
|
|
|
authenticateUser(type, isActive, authProv) {
|
|
|
|
|
//GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
// if (type == 2 || type == 3) {
|
|
|
|
|
// fingrePrintBefore = type;
|
|
|
|
|
// }
|
|
|
|
|
//this.selectedOption = fingrePrintBefore != null ? fingrePrintBefore : type;
|
|
|
|
|
if (type == 3 || type == 4) {
|
|
|
|
|
fingrePrintBefore = type;
|
|
|
|
|
}
|
|
|
|
|
this.selectedOption = fingrePrintBefore != null ? fingrePrintBefore : type;
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 1:
|
|
|
|
@ -657,55 +656,14 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// sharedPref.setInt(LAST_LOGIN,
|
|
|
|
|
// this.selectedOption); //this.cs.sharedService.setStorage(this.selectedOption, AuthenticationService.LAST_LOGIN);
|
|
|
|
|
sharedPref.setInt(OTP_TYPE, selectedOption);
|
|
|
|
|
// sharedPref.setInt(LAST_LOGIN),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loginWithSMS(type, isActive, authProv) {
|
|
|
|
|
this.sendActivationCode(type, authProv);
|
|
|
|
|
// //if (!el.disabled) {
|
|
|
|
|
// if (this.user != null) {
|
|
|
|
|
// this.checkUserAuthentication(type);
|
|
|
|
|
// } else {
|
|
|
|
|
// // if (this.loginTokenID != null) {
|
|
|
|
|
// this.sendActivationCode(type, authProv);
|
|
|
|
|
// // } else {
|
|
|
|
|
// //this.checkUserAuthentication(type);
|
|
|
|
|
// // }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// checkUserAuthentication(type) {
|
|
|
|
|
// // showLoader(true);
|
|
|
|
|
// // var req = getCommonRequest(type: type);
|
|
|
|
|
// // req.logInTokenID = "";
|
|
|
|
|
|
|
|
|
|
// // var request = CheckPatientAuthenticationReq.fromJson(req.toJson());
|
|
|
|
|
|
|
|
|
|
// // sharedPref.setObject(REGISTER_DATA_FOR_REGISTER, request);
|
|
|
|
|
// // authService
|
|
|
|
|
// // .checkPatientAuthentication(request)
|
|
|
|
|
// // .then((value) => {
|
|
|
|
|
// // GifLoaderDialogUtils.hideDialog(context),
|
|
|
|
|
// // if (value['isSMSSent'])
|
|
|
|
|
// // {
|
|
|
|
|
// // sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']),
|
|
|
|
|
// // this.loginTokenID = value['LogInTokenID'],
|
|
|
|
|
// // sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request),
|
|
|
|
|
// // // Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
// // this.sendActivationCode(type)
|
|
|
|
|
// // // })
|
|
|
|
|
// // }
|
|
|
|
|
// // else
|
|
|
|
|
// // {
|
|
|
|
|
// // if (value['IsAuthenticated']) {this.checkActivationCode()}
|
|
|
|
|
// // }
|
|
|
|
|
// // })
|
|
|
|
|
// // .catchError((err) {
|
|
|
|
|
// // print(err);
|
|
|
|
|
// // GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
// // });
|
|
|
|
|
// }
|
|
|
|
|
Future<void> _getAvailableBiometrics() async {
|
|
|
|
|
var availableBiometrics;
|
|
|
|
|
try {
|
|
|
|
@ -729,11 +687,10 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startSMSService(type, authProv) {
|
|
|
|
|
sharedPref.setInt(OTP_TYPE, type);
|
|
|
|
|
new SMSOTP(
|
|
|
|
|
context,
|
|
|
|
|
type,
|
|
|
|
|
_loggedUser['MobileNumber'],
|
|
|
|
|
_loggedUser != null ? _loggedUser['MobileNumber'] : user.mobile,
|
|
|
|
|
(value) {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
@ -746,7 +703,7 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
this.checkActivationCode(authProv, value: value);
|
|
|
|
|
},
|
|
|
|
|
() => {
|
|
|
|
|
Navigator.pop(context),
|
|
|
|
|
//Navigator.pop(context),
|
|
|
|
|
print('Faild..'),
|
|
|
|
|
},
|
|
|
|
|
).displayDialog(context);
|
|
|
|
@ -759,31 +716,29 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
localizedReason: 'Scan your fingerprint to authenticate',
|
|
|
|
|
useErrorDialogs: true,
|
|
|
|
|
stickyAuth: true);
|
|
|
|
|
if (user.logInTypeID == 1 || user.logInTypeID == 2) {
|
|
|
|
|
this.onlySMSBox = true;
|
|
|
|
|
if (user != null && (user.logInTypeID == 3 || user.logInTypeID == 4)) {
|
|
|
|
|
this.sendActivationCode(type, authProv);
|
|
|
|
|
// this.checkActivationCode(authProv);
|
|
|
|
|
} else {
|
|
|
|
|
this.checkActivationCode(authProv);
|
|
|
|
|
setState(() {
|
|
|
|
|
this.onlySMSBox = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if (authenticated == true) {
|
|
|
|
|
// if (user != null && (user.logInTypeID == 4 || user.logInTypeID == 3)) {
|
|
|
|
|
// //this.checkActivationCode();
|
|
|
|
|
// } else {
|
|
|
|
|
// // var request = this.getCommonRequest(type: type);
|
|
|
|
|
// // this.getMobileInfo(request);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkActivationCode(AuthViewModel authProv, {value}) async {
|
|
|
|
|
CheckActivationCodeRequestModel checkActivationCodeForDoctorApp =
|
|
|
|
|
new CheckActivationCodeRequestModel(
|
|
|
|
|
zipCode: _loggedUser['ZipCode'],
|
|
|
|
|
mobileNumber: _loggedUser['MobileNumber'],
|
|
|
|
|
projectID: await sharedPref.getInt(PROJECT_ID),
|
|
|
|
|
zipCode:
|
|
|
|
|
_loggedUser != null ? _loggedUser['ZipCode'] : user.zipCode,
|
|
|
|
|
mobileNumber:
|
|
|
|
|
_loggedUser != null ? _loggedUser['MobileNumber'] : user.mobile,
|
|
|
|
|
projectID: await sharedPref.getInt(PROJECT_ID) != null
|
|
|
|
|
? await sharedPref.getInt(PROJECT_ID)
|
|
|
|
|
: user.projectID,
|
|
|
|
|
logInTokenID: await sharedPref.getString(LOGIN_TOKEN_ID),
|
|
|
|
|
activationCode: value,
|
|
|
|
|
activationCode: value ?? '0000',
|
|
|
|
|
oTPSendType: await sharedPref.getInt(OTP_TYPE),
|
|
|
|
|
generalid: "Cs2020@2016\$2958");
|
|
|
|
|
|
|
|
|
|