Skip to content

fix(auth): carry team/org invite context through social OAuth sign-in - #467

Merged
Dharp02 merged 1 commit into
mainfrom
fix/oauth-social-signin-team-org-join
Jul 30, 2026
Merged

fix(auth): carry team/org invite context through social OAuth sign-in#467
Dharp02 merged 1 commit into
mainfrom
fix/oauth-social-signin-team-org-join

Conversation

@Dharp02

@Dharp02 Dharp02 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Signing in with Google, GitHub, or Apple from a team invite, org invite, or QR join link silently dropped that context — the OAuth-initiation URL never carried invite/org_invite/join, and the backend's state param only ever encoded a native_ native-app flag. The user ended up authenticated but never added to the team/org they meant to join.
  • Threads join/invite/org_invite through the full redirect-away-and-back OAuth round trip so social sign-in reaches parity with the existing password-flow login, which already calls acceptTeamInvitation/acceptOrgInvitation/joinTeamByQrCode before redirecting.

Changes

  • src/ui/LoginForm.tsx: attach join/invite/org_invite to 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 OAuth state param (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 the timehuddle://auth deep 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 — clean
  • npx eslint src/main.tsx src/ui/LoginForm.tsx — clean
  • node --check meteor-backend/server/main.js — clean
  • npx vitest run src/ui/LoginForm.test.tsx — passing
  • Manual smoke test: click a team-invite link, sign in with Google, confirm landing in the invited team
  • Manual smoke test: same for GitHub and Apple, and for org-invite / QR-join links
  • Manual smoke test: native (Capacitor) build, same flows via the timehuddle://auth deep link

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

🚀 Preview Deployment Ready

Service URL
App https://mieweb-timehuddle-fix-oauth-social-signin-team-org-join.os.mieweb.org
API (Meteor) https://mieweb-timehuddle-fix-oauth-social-signin-team-org-join-api.os.mieweb.org

Preview auto-deletes when this PR is closed.

@Dharp02
Dharp02 merged commit 9b7dfe0 into main Jul 30, 2026
7 checks passed
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