Skip to content

Provision YustUser after OAuth redirect sign-in (completeSignInWithRedirect) - #423

Open
CLNMR wants to merge 1 commit into
masterfrom
fix-oauth-redirect-yust-user
Open

Provision YustUser after OAuth redirect sign-in (completeSignInWithRedirect)#423
CLNMR wants to merge 1 commit into
masterfrom
fix-oauth-redirect-yust-user

Conversation

@CLNMR

@CLNMR CLNMR commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Problem

On web, OAuth sign-in with redirect: true uses Firebase's signInWithRedirect, which navigates the whole page away to the identity provider and reloads the app on return. That reload discards the in-flight signInWith... call before it reaches the link/create logic, so _signInWithProvider never provisions a YustUser. Firebase restores the AuthUser from persistence, but the YustUser document 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

  • Add completeSignInWithRedirect() to the auth service. On web it calls getRedirectResult() and, when a sign-in just completed, links or creates the matching YustUser (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.
  • Extract the shared link/create logic into _provisionYustUser, reused by both _signInWithProvider and the new method.
  • Add matching no-op 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

  • Idempotent: if the redirect user already has a YustUser (matched by authId), no duplicate is created.
  • Version bumped to 3.35.0. (origin/master was at 3.33.2; there is unpublished local 3.34.0 WIP on some checkouts — this intentionally lands as 3.35.0 to avoid colliding with it and to match the app's ^3.35.0 constraint.)

🤖 Generated with Claude Code

…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
@CLNMR

CLNMR commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

App-side companion PR that calls this at startup: univelop/univelop#7728

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