openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Fix account switching causing data loss and forced re-onboarding after re-login

Open Al629176 opened this issue 7 months ago • 2 comments

Summary

Fix account switching/session persistence bug where logging out, logging into another account, then returning to the first account causes full re-onboarding and loss of prior chat/login/connection data.

Problem

When a user:

  1. logs out of account 1,
  2. logs into account 2,
  3. logs back into account 1,

the app treats account 1 like a fresh user and sends them through the full onboarding/login flow again. Existing account 1 data appears missing, including:

  • chat history
  • login/session state
  • connected integrations / connection data

Expected Behavior

  • Returning to account 1 should restore account 1 state.
  • Existing chat history should remain available.
  • Connected integrations should remain linked.
  • User should not be forced through full onboarding again unless account truly has no onboarding state.

Scope

  • Reproduce logout/account-switch/account-return flow.
  • Audit account-scoped storage and persisted state keys.
  • Ensure chat data, login data, onboarding completion, and connection data are scoped per account/user ID.
  • Fix any state reset/clear logic that wipes all accounts instead of active account/session only.
  • Rehydrate correct account state after login.
  • Add safeguards to prevent cross-account data leakage while preserving each account's own data.
  • Add logs for account switch, state clear, and state restore operations.

Acceptance Criteria

  • Account 1 data is restored after switching to account 2 and back.
  • User is not re-onboarded if account 1 already completed onboarding.
  • Chat history and integrations remain attached to the correct account.
  • Logging out does not delete persistent account data unless explicitly requested.
  • No cross-account data leakage occurs.
  • Tests cover account switch and re-login persistence behavior.

Al629176 avatar Apr 27 '26 12:04 Al629176

Linked to parent issue #972.

Al629176 avatar Apr 27 '26 12:04 Al629176

The issue has already been fixed and no further updation is needed for this issue. Tested it end to end! When I tested it end to end, the messages and connections persists for account 1.

YellowSnnowmann avatar May 05 '26 07:05 YellowSnnowmann