diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index 41664758..39d8e3ee 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -313,7 +313,11 @@ class AuthenticationRepoImp implements AuthenticationRepo { requestBody['ProjectOutSA'] = 0; requestBody['PatientIdentificationID'] = ""; requestBody.removeWhere((key, value) => ['NationalID', 'isDentalAllowedBackend', 'ForRegisteration'].contains(key)); + appState.setIsChildLoggedIn = false; + appState.clearUserSwitchPayloads(); } + } else { + appState.setIsChildLoggedIn = true; } } diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index 2055deea..7e753722 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -280,13 +280,13 @@ class AuthenticationViewModel extends ChangeNotifier { onSuccess: (dynamic respData) async { try { if (respData != null) { - dynamic data = await SelectDeviceByImeiRespModelElement.fromJson(respData.toJson()); - _appState.setSelectDeviceByImeiRespModelElement(data); - LoaderBottomSheet.hideLoader(); + dynamic data = await SelectDeviceByImeiRespModelElement.fromJson(respData.toJson()); + _appState.setSelectDeviceByImeiRespModelElement(data); + LoaderBottomSheet.hideLoader(); - // TODO: Navigate to SavedLogin when available - // SelectDeviceByImeiRespModelElement savedData = - // SelectDeviceByImeiRespModelElement.fromJson(respData); + // TODO: Navigate to SavedLogin when available + // SelectDeviceByImeiRespModelElement savedData = + // SelectDeviceByImeiRespModelElement.fromJson(respData); if (!isInitialLoginNavigated) { _navigationService.pushPage(page: SavedLogin()); } @@ -304,10 +304,11 @@ class AuthenticationViewModel extends ChangeNotifier { _navigationService.pushPage(page: LoginScreen()); } } - }, onError: (String error) { - LoaderBottomSheet.hideLoader(); - _dialogService.showErrorBottomSheet(message: error, onOkPressed: () {}); - }); + }, + onError: (String error) { + LoaderBottomSheet.hideLoader(); + _dialogService.showErrorBottomSheet(message: error, onOkPressed: () {}); + }); } Future checkUserAuthentication({required OTPTypeEnum otpTypeEnum, Function(dynamic)? onSuccess, Function(String)? onError}) async { @@ -631,8 +632,8 @@ class AuthenticationViewModel extends ChangeNotifier { if (isSwitchUser) { if (_appState.getIsChildLoggedIn) { _appState.setSuperUserID = null; - _appState.setIsChildLoggedIn = false; - activation.list!.first.isParentUser = true; + // _appState.setIsChildLoggedIn = false; + activation.list!.first.isParentUser = false; var allUsersPayload = _appState.getUserSwitchPayloads; if ((allUsersPayload.containsKey('superUser') && allUsersPayload['superUser'] != null)) { _appState.addUserSwitchPayload(activation.list!.first.toJson(), isSuperUser: false); @@ -641,9 +642,9 @@ class AuthenticationViewModel extends ChangeNotifier { } } else { _appState.setSuperUserID = _appState.getAuthenticatedUser()?.patientId; - _appState.setIsChildLoggedIn = true; - activation.list!.first.isParentUser = false; - _appState.addUserSwitchPayload(activation.list!.first.toJson(), isSuperUser: false); + // _appState.setIsChildLoggedIn = false; + activation.list!.first.isParentUser = true; + _appState.addUserSwitchPayload(activation.list!.first.toJson(), isSuperUser: true); } } else { activation.list!.first.isParentUser = true;