|
|
|
@ -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,55 +384,50 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
sendActivationCodeVerificationScreen(
|
|
|
|
|
oTPSendType, AuthViewModel authProv) async {
|
|
|
|
|
// TODO : build enum for verfication method
|
|
|
|
|
if (oTPSendType == 1 || oTPSendType == 2) {
|
|
|
|
|
widget.changeLoadingStata(true);
|
|
|
|
|
ActivationCodeModel2 activationCodeModel = ActivationCodeModel2(
|
|
|
|
|
facilityId: user.projectID,
|
|
|
|
|
memberID: user.doctorID,
|
|
|
|
|
zipCode: user.outSA == true ? '971' : '966',
|
|
|
|
|
mobileNumber: user.mobile,
|
|
|
|
|
oTPSendType: oTPSendType,
|
|
|
|
|
isMobileFingerPrint: 1,
|
|
|
|
|
vidaAuthTokenID: user.vidaAuthTokenID,
|
|
|
|
|
vidaRefreshTokenID: user.vidaRefreshTokenID);
|
|
|
|
|
//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',
|
|
|
|
|
mobileNumber: user.mobile,
|
|
|
|
|
oTPSendType: oTPSendType,
|
|
|
|
|
isMobileFingerPrint: 1,
|
|
|
|
|
vidaAuthTokenID: user.vidaAuthTokenID,
|
|
|
|
|
vidaRefreshTokenID: user.vidaRefreshTokenID);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
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"]);
|
|
|
|
|
try {
|
|
|
|
|
authProv
|
|
|
|
|
.sendActivationCodeVerificationScreen(activationCodeModel)
|
|
|
|
|
.then((res) {
|
|
|
|
|
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 {
|
|
|
|
|
print(res['ErrorEndUserMessage']);
|
|
|
|
|
helpers.showErrorToast(res['ErrorEndUserMessage']);
|
|
|
|
|
checkActivationCode(authProv);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print('$err');
|
|
|
|
|
widget.changeLoadingStata(false);
|
|
|
|
|
|
|
|
|
|
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,)));
|
|
|
|
|
} else {
|
|
|
|
|
print(res['ErrorEndUserMessage']);
|
|
|
|
|
helpers.showErrorToast(res['ErrorEndUserMessage']);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print('$err');
|
|
|
|
|
widget.changeLoadingStata(false);
|
|
|
|
|
|
|
|
|
|
// Navigator.of(context).pushNamed(VERIFICATION_METHODS,
|
|
|
|
|
// arguments: {'verificationMethod': oTPSendType});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
helpers.showErrorToast();
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
// }
|
|
|
|
|
// 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,8 +656,8 @@ 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) {
|
|
|
|
@ -729,11 +728,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,
|
|
|
|
@ -759,10 +757,13 @@ 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) {
|
|
|
|
@ -779,11 +780,15 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|