Repository navigation
Conversation
Adds a `SignOutReason` enum (userInitiated, sessionExpired, sessionMissing) exposed via `AuthState.signOutReason`, so listeners can tell an explicit sign out apart from an involuntary one without inspecting error messages. The reason is threaded through `notifyAllSubscribers` and set on every local sign-out path: explicit `signOut`, a non-retryable refresh failure, and `recoverSession`/`setInitialSession` when the stored session is expired or missing data. It is intentionally not broadcast across tabs. The involuntary `recoverSession`/`setInitialSession` exceptions now also carry stable `session_expired` / `session_missing` error codes (added to `ErrorCode`) so the same reason is available on the stream error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a typed
SignOutReasonto thesignedOutauth state so listeners can tell an explicit sign out apart from an involuntary one (e.g. an expired session) without inspecting error messages.This is an alternative to attaching a raw
AuthExceptiontoAuthState(proposed in #1453). A small, client-owned enum gives a stable, discoverable contract, keepsAuthStatea clean value type, and avoids dragging the exception hierarchy into itstoString/equality.Changes
SignOutReasonenum:userInitiated,sessionExpired,sessionMissing.AuthState.signOutReason(nullable) — set only onsignedOut,nullotherwise and forsignedOutevents received from another tab viaBroadcastChannel.notifyAllSubscribersand set on every local sign-out path:signOut()→userInitiated_executeRefresh→sessionExpiredrecoverSession/setInitialSessionwith an expired/missing session →sessionExpired/sessionMissingrecoverSession/setInitialSessionexceptions previously carried only a human-readable message. They now also carry stablesession_expired/session_missingcodes (added toErrorCode), so the same reason is available whether you read it from thesignedOutstate or from the stream error.Tests
Extended
token_refresh_race_test.dartto assert the reason on a refresh failure, an explicit sign out, andrecoverSessionwith an expired session.