fix(auth): carry team/org invite context through social OAuth sign-in - #467
Merged
Conversation
Signing in with Google, GitHub, or Apple from a team invite, org invite, or QR join link dropped that context entirely: the OAuth-initiation URL never carried it, and the backend's `state` param only ever encoded a `native_` flag, so the user landed back in the app authenticated but never added to the team/org they meant to join. Thread join/invite/org_invite through the full redirect-away-and-back OAuth round trip: - LoginForm attaches join/invite/org_invite to the OAuth-initiation URL - meteor-backend packs them into the OAuth `state` param (base64url JSON) so they survive the trip to the IdP and back, then re-attaches them to the redirect back to the frontend (native deep link and web) - main.tsx reads them on landing (URL on web, timehuddle://auth deep link on native) and calls the same acceptTeamInvitation / acceptOrgInvitation / joinTeamByQrCode DDP methods the password-flow login already used Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
🚀 Preview Deployment Ready
Preview auto-deletes when this PR is closed. |
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.
Summary
invite/org_invite/join, and the backend'sstateparam only ever encoded anative_native-app flag. The user ended up authenticated but never added to the team/org they meant to join.join/invite/org_invitethrough the full redirect-away-and-back OAuth round trip so social sign-in reaches parity with the existing password-flow login, which already callsacceptTeamInvitation/acceptOrgInvitation/joinTeamByQrCodebefore redirecting.Changes
src/ui/LoginForm.tsx: attachjoin/invite/org_inviteto the OAuth-initiation URL (both the Meteor OAuth path and the existing oauth2/social callback URL).meteor-backend/server/main.js: pack join/invite context into the OAuthstateparam (encodeOAuthState/decodeOAuthState, base64url JSON) so it survives the trip to the IdP and back; re-attach it to the redirect back to the frontend for GitHub, Google, and Apple callbacks — both the native deep link (timehuddle://auth) and the web redirect.src/main.tsx: read the join/invite context on landing — from the URL on web, from thetimehuddle://authdeep link on native (module-level_pendingOAuthJoin, since native has no URL bar to read from) — and call the same DDP accept/join methods the password-flow already uses, once a session is established.Test plan
npm run typecheck— cleannpx eslint src/main.tsx src/ui/LoginForm.tsx— cleannode --check meteor-backend/server/main.js— cleannpx vitest run src/ui/LoginForm.test.tsx— passingtimehuddle://authdeep link🤖 Generated with Claude Code