Skip to content

fix(auth): stop silent reconnect after logout without data wipe#418

Merged
mremond merged 2 commits into
mainfrom
fix/logout-auto-reconnect
May 25, 2026
Merged

fix(auth): stop silent reconnect after logout without data wipe#418
mremond merged 2 commits into
mainfrom
fix/logout-auto-reconnect

Conversation

@mremond
Copy link
Copy Markdown
Member

@mremond mremond commented May 25, 2026

Summary

On the desktop (Tauri) app, choosing Déconnexion without ticking Effacer les données locales reconnected the user immediately.

Root cause: the XEP-0484 FAST token survived the logout. After disconnect, LoginScreen reloads the webview (WRY event-delivery workaround), which resets useSessionPersistence's once-per-startup auto-reconnect guard — so the post-reload auto-connect path re-authenticated with the surviving token. The clean ("clear data") path was unaffected because clearLocalData already drops the token synchronously.

Two layers of fix for the same cause:

  • App — the no-clean logout path now clears the FAST token synchronously, before the reload can fire (new clearAutoReconnectCredentials helper). The keychain credentials were already being deleted there; only the FAST token was missed.
  • SDKdisconnect({ invalidateFastToken: true }) deleted the local token only after awaiting the best-effort, network-bound server invalidation, which the reload could outrace. It now captures the token and deletes the local copy in the synchronous phase, then threads the captured token through to invalidateFastTokenOnServer (new optional token param) so the server-side invalidation still works.

Behavior of the "clear local data" path is unchanged.

mremond added 2 commits May 25, 2026 15:23
A logout without "clear local data" left the XEP-0484 FAST token in
localStorage. On Tauri, LoginScreen reloads the webview after disconnect
(WRY event-delivery workaround), which resets useSessionPersistence's
once-per-startup guard, so the post-reload auto-connect path re-authenticated
with the surviving token — silently reconnecting the user we just logged out.

Clear the token synchronously in the no-clean logout path, before the reload
can occur, via a new clearAutoReconnectCredentials helper.
disconnect({ invalidateFastToken: true }) deleted the client-side FAST token
only after awaiting the best-effort, network-bound server invalidation. On
Tauri the post-logout webview reload can tear down the JS context before that
await settles, leaving a usable token behind that re-enabled auto-reconnect.

Capture the token and delete the local copy in the synchronous phase (same
tick the UI goes 'disconnected'), then thread the captured token through to
invalidateFastTokenOnServer so the server-side round-trip can still
authenticate to invalidate it. invalidateFastTokenOnServer now accepts an
optional pre-fetched token and only skips the localStorage lookup when given.
@mremond mremond merged commit b8641fc into main May 25, 2026
2 checks passed
@mremond mremond deleted the fix/logout-auto-reconnect branch May 25, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant