Skip to content

Multi-account authentication: sign in with several accounts and switch between them #493

Description

@aymericzip

Low priority / nice to have.

Context

Today the app holds exactly one session at a time. Signing into another account replaces the current one, and switching back means signing out and signing in again. This is especially visible with the demo session: entering the demo blows away an existing login (see the "you are currently logged in, switch to demo?" prompt in apps/app/src/routes/{-$locale}/demo.tsx).

Proposal

Support several authenticated accounts side by side in the browser, like the Google account switcher:

  • Keep multiple valid sessions simultaneously.
  • An account switcher in the dashboard user menu listing every signed-in account, with the active one marked.
  • "Add another account" → sign-in flow that adds a session instead of replacing the current one.
  • Sign out of one account without dropping the others.
  • The demo session becomes just another entry in the list, so trying the demo no longer kicks you out of your real account.

Implementation notes

  • The backend already runs better-auth 1.6.29 (apps/backend/src/utils/auth/getAuth.ts, currently with the customSession, passkey and sso plugins). better-auth ships a multiSession plugin that covers the storage/cookie side, so this is mostly plugin wiring + UI.
  • Client side, the session is read through sessionQueryOptions (apps/app/src/utils/auth.tsx); the switcher will need to invalidate/refetch on account change, and the active organization / active project resolution must follow the newly active account.
  • UI belongs in @intlayer/design-system so both the dashboard and the visual editor can use it.

Acceptance criteria

  • Two or more accounts can be signed in at once.
  • Switcher in the user menu, active account marked, switching is instant (no re-login).
  • Signing out of one account keeps the others alive.
  • Active organization / project follow the switched account.
  • Entering the demo does not destroy an existing authenticated session.

Metadata

Metadata

Assignees

No one assigned

    Labels

    appRelated to the appbackendRelated to the Intlayer backend package / appfeatureA request, idea, or new functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions