diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index 7fe9297..2ed43d8 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -28,7 +28,9 @@ abstract class AuthenticationRepo { int? patientShareRequestID, int? responseID, bool isSwitchUser = false, - int? patientID}); + int? patientID, + int? loginType + }); Future>> checkIfUserAgreed({required dynamic commonAuthanticatedRequest}); @@ -192,6 +194,7 @@ class AuthenticationRepoImp implements AuthenticationRepo { int? responseID, bool isSwitchUser = false, int? patientID, + int? loginType }) async { if (isRegister) { newRequest["activationCode"] = activationCode ?? "0000"; @@ -215,12 +218,19 @@ class AuthenticationRepoImp implements AuthenticationRepo { Map switchRequest = {}; if (isSwitchUser) { switchRequest = newRequest.toJson(); - switchRequest['SuperUser'] = patientID; + switchRequest['PatientID'] = responseID; switchRequest['IsSilentLogin'] = true; switchRequest['LogInTokenID'] = null; - switchRequest['DeviceToken'] = null; switchRequest['SearchType'] = 2; + if(loginType != 0) { + switchRequest['SuperUser'] = patientID; + switchRequest['DeviceToken'] = null; + }else{ + switchRequest['LoginType'] = 2; + } + + } final endpoint = isFormFamilyFile diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index d42c8cf..8cb5eed 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -247,7 +247,7 @@ class AuthenticationViewModel extends ChangeNotifier { await selectDeviceImei(onSuccess: (dynamic respData) async { try { if (respData != null) { - dynamic data = SelectDeviceByImeiRespModelElement.fromJson(respData.toJson()); + dynamic data = await SelectDeviceByImeiRespModelElement.fromJson(respData.toJson()); _appState.setSelectDeviceByImeiRespModelElement(data); LoaderBottomSheet.hideLoader(); @@ -440,7 +440,8 @@ class AuthenticationViewModel extends ChangeNotifier { dynamic patientShareRequestID, dynamic responseID, bool isSwitchUser =false, - int? patientID + int? patientID, + }) async { bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true || _appState.getUserRegistrationPayload.patientOutSa == 1); @@ -515,7 +516,8 @@ class AuthenticationViewModel extends ChangeNotifier { patientShareRequestID: patientShareRequestID, responseID: responseID, isSwitchUser: isSwitchUser, - patientID: patientID + patientID: patientID, + loginType: _appState.superUserID != null ? 0 : 2, ); resultEither.fold( diff --git a/lib/features/medical_file/medical_file_view_model.dart b/lib/features/medical_file/medical_file_view_model.dart index 51836a6..aa77700 100644 --- a/lib/features/medical_file/medical_file_view_model.dart +++ b/lib/features/medical_file/medical_file_view_model.dart @@ -275,7 +275,9 @@ class MedicalFileViewModel extends ChangeNotifier { ? phoneNumber.replaceFirst("0", "") : phoneNumber; - await authVM.checkActivationCode(activationCode: '0000', otpTypeEnum: OTPTypeEnum.sms, onWrongActivationCode: (String? str) {}, responseID: responseID, isFormFamilyFile:false, isSwitchUser: true, patientID: patientID); + + + await authVM.checkActivationCode(activationCode: '0000', otpTypeEnum: OTPTypeEnum.sms, onWrongActivationCode: (String? str) {}, responseID: responseID, isFormFamilyFile:false, isSwitchUser: true, patientID: patientID, ); }