|
|
|
@ -289,7 +289,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
await checkActivationCode(
|
|
|
|
await checkActivationCode(
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
onWrongActivationCode: (String? message) {},
|
|
|
|
onWrongActivationCode: (String? message) {},
|
|
|
|
activationCode: 0000,
|
|
|
|
activationCode: null, //todo silent login case halded on the repo itself..
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -360,7 +360,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> checkActivationCode({
|
|
|
|
Future<void> checkActivationCode({
|
|
|
|
required int activationCode,
|
|
|
|
required String? activationCode,
|
|
|
|
required OTPTypeEnum otpTypeEnum,
|
|
|
|
required OTPTypeEnum otpTypeEnum,
|
|
|
|
required Function(String? message) onWrongActivationCode,
|
|
|
|
required Function(String? message) onWrongActivationCode,
|
|
|
|
}) async {
|
|
|
|
}) async {
|
|
|
|
@ -373,9 +373,10 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
registeredData: null,
|
|
|
|
registeredData: null,
|
|
|
|
nationIdText: nationalIdController.text,
|
|
|
|
nationIdText: nationalIdController.text,
|
|
|
|
countryCode: selectedCountrySignup.countryCode,
|
|
|
|
countryCode: selectedCountrySignup.countryCode,
|
|
|
|
|
|
|
|
loginType: loginTypeEnum.toInt
|
|
|
|
).toJson();
|
|
|
|
).toJson();
|
|
|
|
|
|
|
|
|
|
|
|
bool isForRegister = _appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true;
|
|
|
|
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true);
|
|
|
|
if (isForRegister) {
|
|
|
|
if (isForRegister) {
|
|
|
|
if (_appState.getUserRegistrationPayload.patientOutSa == true) request['DOB'] = _appState.getUserRegistrationPayload.dob;
|
|
|
|
if (_appState.getUserRegistrationPayload.patientOutSa == true) request['DOB'] = _appState.getUserRegistrationPayload.dob;
|
|
|
|
request['HealthId'] = _appState.getUserRegistrationPayload.healthId;
|
|
|
|
request['HealthId'] = _appState.getUserRegistrationPayload.healthId;
|
|
|
|
@ -396,7 +397,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
final resultEither = await _authenticationRepo.checkActivationCodeRepo(
|
|
|
|
final resultEither = await _authenticationRepo.checkActivationCodeRepo(
|
|
|
|
newRequest: CheckActivationCodeRegisterReq.fromJson(request),
|
|
|
|
newRequest: CheckActivationCodeRegisterReq.fromJson(request),
|
|
|
|
activationCode: activationCode.toString(),
|
|
|
|
activationCode: activationCode,
|
|
|
|
isRegister: false,
|
|
|
|
isRegister: false,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
@ -422,6 +423,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
_appState.setAppAuthToken = activation.authenticationTokenId;
|
|
|
|
_appState.setAppAuthToken = activation.authenticationTokenId;
|
|
|
|
final request = RequestUtils.getAuthanticatedCommonRequest().toJson();
|
|
|
|
final request = RequestUtils.getAuthanticatedCommonRequest().toJson();
|
|
|
|
bool isUserAgreedBefore = await checkIfUserAgreedBefore(request: request);
|
|
|
|
bool isUserAgreedBefore = await checkIfUserAgreedBefore(request: request);
|
|
|
|
|
|
|
|
insertPatientIMEIData(loginTypeEnum.toInt);
|
|
|
|
clearDefaultInputValues();
|
|
|
|
clearDefaultInputValues();
|
|
|
|
if (isUserAgreedBefore) {
|
|
|
|
if (isUserAgreedBefore) {
|
|
|
|
navigateToHomeScreen();
|
|
|
|
navigateToHomeScreen();
|
|
|
|
@ -491,7 +493,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
checkActivationCode: (int activationCode) async {
|
|
|
|
checkActivationCode: (int activationCode) async {
|
|
|
|
await checkActivationCode(
|
|
|
|
await checkActivationCode(
|
|
|
|
activationCode: activationCode,
|
|
|
|
activationCode: activationCode.toString(),
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
onWrongActivationCode: (String? value) {
|
|
|
|
onWrongActivationCode: (String? value) {
|
|
|
|
onWrongActivationCode(message: value);
|
|
|
|
onWrongActivationCode(message: value);
|
|
|
|
@ -508,12 +510,19 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
loginWithFingerPrintFace() async {
|
|
|
|
loginWithFingerPrintFace() async {
|
|
|
|
_localAuthService.authenticate().then((value) {
|
|
|
|
_localAuthService.authenticate().then((value) async {
|
|
|
|
if (value) {
|
|
|
|
if (value) {
|
|
|
|
// we have to handle this if verification true;
|
|
|
|
// we have to handle this if verification true;
|
|
|
|
// checkActivationCode(otpTypeEnum: OTPTypeEnum.faceIDFingerprint, activationCode: 0000, onWrongActivationCode: (String? message) {});
|
|
|
|
if(!_appState.isAuthenticated) {
|
|
|
|
// authenticated = true;
|
|
|
|
loginTypeEnum = (_appState.deviceTypeID == 1 ? LoginTypeEnum.face : LoginTypeEnum.fingerprint);
|
|
|
|
insertPatientIMEIData( OTPTypeEnum.faceIDFingerprint.toInt());
|
|
|
|
print(loginTypeEnum);
|
|
|
|
|
|
|
|
checkActivationCode(otpTypeEnum:OTPTypeEnum.faceIDFingerprint , activationCode: null, onWrongActivationCode: (String? message) {});
|
|
|
|
|
|
|
|
insertPatientIMEIData((_appState.deviceTypeID == 1 ? LoginTypeEnum.face.toInt : LoginTypeEnum.fingerprint.toInt));
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
// authenticated = true;
|
|
|
|
|
|
|
|
insertPatientIMEIData((_appState.deviceTypeID == 1 ? LoginTypeEnum.face.toInt : LoginTypeEnum.fingerprint.toInt));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
// navigateToHomeScreen();
|
|
|
|
// navigateToHomeScreen();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -521,7 +530,6 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
checkLastLoginStatus(Function() onSuccess) async {
|
|
|
|
checkLastLoginStatus(Function() onSuccess) async {
|
|
|
|
@ -696,25 +704,25 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> insertPatientIMEIData(int loginType) async{
|
|
|
|
Future<void> insertPatientIMEIData(int loginType) async{
|
|
|
|
|
|
|
|
|
|
|
|
final resultEither = await _authenticationRepo.insertPatientIMEIData(patientIMEIDataRequest: PatientInsertDeviceImei(imei: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), patientId: _appState.getAuthenticatedUser()!.patientId!, patientIdentificationNo:_appState.getAuthenticatedUser()!.nationalityId!, firstName: _appState.getAuthenticatedUser()!.firstName!, lastName: _appState.getAuthenticatedUser()!.lastName!, patientTypeId: _appState.getAuthenticatedUser()!.patientType, mobileNo:_appState.getAuthenticatedUser()!.mobileNumber!, logInTypeId: loginType, patientOutSa:_appState.getAuthenticatedUser()!.outSa! ).toJson());
|
|
|
|
final resultEither = await _authenticationRepo.insertPatientIMEIData(patientIMEIDataRequest: PatientInsertDeviceImei(imei: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), patientId: _appState.getAuthenticatedUser()!.patientId!, patientIdentificationNo:_appState.getAuthenticatedUser()!.nationalityId!, firstName: _appState.getAuthenticatedUser()!.firstName!, lastName: _appState.getAuthenticatedUser()!.lastName!, patientTypeId: _appState.getAuthenticatedUser()!.patientType, mobileNo:_appState.getAuthenticatedUser()!.mobileNumber!, logInTypeId: loginType, patientOutSa:_appState.getAuthenticatedUser()!.outSa!, outSa: _appState.getAuthenticatedUser()!.outSa == 1 ? true :false, biometricEnabled: loginType == 1 || loginType ==2 ? false :true, firstNameN:_appState.getAuthenticatedUser()!.firstNameN , lastNameN:_appState.getAuthenticatedUser()!.lastNameN ).toJson());
|
|
|
|
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
|
|
|
|
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
|
|
|
|
if (apiResponse.messageStatus == 1) {
|
|
|
|
if (apiResponse.messageStatus == 1) {
|
|
|
|
print("Insert IMEI Success");
|
|
|
|
log("Insert IMEI Success");
|
|
|
|
insertPatientDeviceData( loginType);
|
|
|
|
insertPatientDeviceData( loginType);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
print("Insert IMEI Failed");
|
|
|
|
log("Insert IMEI Failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Future<void> insertPatientDeviceData(int loginType) async{
|
|
|
|
Future<void> insertPatientDeviceData(int loginType) async{
|
|
|
|
|
|
|
|
|
|
|
|
final resultEither = await _authenticationRepo.insertPatientDeviceData(patientDeviceDataRequest: InsertPatientMobileDeviceInfo(deviceToken: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), patientId: _appState.getAuthenticatedUser()!.patientId!, patientTypeId: _appState.getAuthenticatedUser()!.patientType, patientOutSa:_appState.getAuthenticatedUser()!.outSa!, loginType: loginType, languageId: _appState.getLanguageID(), latitude: _appState.userLat, longitude:_appState.userLong ).toJson());
|
|
|
|
final resultEither = await _authenticationRepo.insertPatientDeviceData(patientDeviceDataRequest: InsertPatientMobileDeviceInfo(deviceToken: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), patientId: _appState.getAuthenticatedUser()!.patientId!, patientTypeId: _appState.getAuthenticatedUser()!.patientType, patientOutSa:_appState.getAuthenticatedUser()!.outSa!, loginType: loginType, languageId: _appState.getLanguageID(), latitude: _appState.userLat, longitude:_appState.userLong, voipToken: "", deviceType: _appState.deviceTypeID, patientMobileNumber:_appState.getAuthenticatedUser()!.mobileNumber, nationalId: _appState.getAuthenticatedUser()!.patientIdentificationNo, gender: _appState.getAuthenticatedUser()!.gender ).toJson());
|
|
|
|
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
|
|
|
|
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
|
|
|
|
if (apiResponse.messageStatus == 1) {
|
|
|
|
if (apiResponse.messageStatus == 1) {
|
|
|
|
print("Insert Device Data Success");
|
|
|
|
log("Insert Device Data Success");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
print("Insert IMEI Failed");
|
|
|
|
log("Insert IMEI Failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|