Provision YustUser after OAuth redirect sign-in (completeSignInWithRedirect) - #423
Open
CLNMR wants to merge 1 commit into
Open
Provision YustUser after OAuth redirect sign-in (completeSignInWithRedirect)#423CLNMR wants to merge 1 commit into
CLNMR wants to merge 1 commit into
Conversation
…h redirect On web, OAuth sign-in with `redirect: true` uses signInWithRedirect, which navigates the page away to the provider and reloads the app on return. That discards the in-flight signInWith... call before it can link/create the YustUser, leaving an authenticated Firebase user with no matching YustUser. Add completeSignInWithRedirect(): on web it fetches getRedirectResult() and, when a sign-in just completed, links or creates the YustUser (auth method derived from the provider id). No-op when there is no pending redirect (safe on every startup) and on non-web. Extract the shared link/create logic into _provisionYustUser, reused by _signInWithProvider. Add matching no-op overrides on the dart and mocked services for interface parity. Callers should invoke completeSignInWithRedirect() once at app startup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X1wHRpzN5EDqhE9fXVWg5T
Contributor
Author
|
App-side companion PR that calls this at startup: univelop/univelop#7728 |
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.
Problem
On web, OAuth sign-in with
redirect: trueuses Firebase'ssignInWithRedirect, which navigates the whole page away to the identity provider and reloads the app on return. That reload discards the in-flightsignInWith...call before it reaches the link/create logic, so_signInWithProvidernever provisions aYustUser. Firebase restores theAuthUserfrom persistence, but theYustUserdocument is never created — leaving an authenticated Firebase user with no matching domain user.This surfaced in the app as: Microsoft login on dev creates only an AuthUser, not a proper YustUser (dev/next/beta web use the redirect flow; prod uses popup and is unaffected).
Change
completeSignInWithRedirect()to the auth service. On web it callsgetRedirectResult()and, when a sign-in just completed, links or creates the matchingYustUser(auth method derived from the provider id). It is a no-op when there is no pending redirect result (safe to call on every startup) and on non-web platforms._provisionYustUser, reused by both_signInWithProviderand the new method.completeSignInWithRedirect()overrides on the dart (server) and mocked services for interface parity.Callers invoke
completeSignInWithRedirect()once at app startup. The univelop side is in univelop#(see linked app PR).Notes
YustUser(matched byauthId), no duplicate is created.3.35.0. (origin/master was at3.33.2; there is unpublished local3.34.0WIP on some checkouts — this intentionally lands as3.35.0to avoid colliding with it and to match the app's^3.35.0constraint.)🤖 Generated with Claude Code