diff --git a/lib/core/app_state.dart b/lib/core/app_state.dart index a5a8d72a..d02aa946 100644 --- a/lib/core/app_state.dart +++ b/lib/core/app_state.dart @@ -249,4 +249,18 @@ class AppState { _userSwitchPayloads.clear(); _childSwitchCounter = 0; } + + void clearChildUsersKeepSuperUser() { + // Keep the super user payload + final superUserPayload = _userSwitchPayloads['superUser']; + + // Clear all payloads + _userSwitchPayloads.clear(); + _childSwitchCounter = 0; + + // Restore super user if it existed + if (superUserPayload != null) { + _userSwitchPayloads['superUser'] = superUserPayload; + } + } } diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index 39d8e3ee..c355819e 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -314,7 +314,7 @@ class AuthenticationRepoImp implements AuthenticationRepo { requestBody['PatientIdentificationID'] = ""; requestBody.removeWhere((key, value) => ['NationalID', 'isDentalAllowedBackend', 'ForRegisteration'].contains(key)); appState.setIsChildLoggedIn = false; - appState.clearUserSwitchPayloads(); + appState.clearChildUsersKeepSuperUser(); } } else { appState.setIsChildLoggedIn = true;