Skip to content

feat(p26): OAuth callback + User.tier column#53

Merged
harsh-pandhe merged 2 commits into
mainfrom
feat/p26-oauth-callback
May 24, 2026
Merged

feat(p26): OAuth callback + User.tier column#53
harsh-pandhe merged 2 commits into
mainfrom
feat/p26-oauth-callback

Conversation

@harsh-pandhe
Copy link
Copy Markdown
Owner

Summary

  • GET /auth/oauth/{provider}/callback: state-cookie verify → code exchange → userinfo fetch → user upsert → JWT mint.
  • User.tier column (default "community") drives the billing feature gates. Idempotent ALTER TABLE migration in init_db so legacy DBs read-compatible.
  • JWT payload carries tier; /auth/me and UserRead expose it.
  • Repeat OAuth login preserves existing tier — P27's webhook is the only mutator.

Why

Closes Phase P26 — the only remaining Wave-1 piece before P27 Razorpay lifecycle can lift users out of community.

Test plan

  • 10 new tests: legacy-DB migration adds tier column, register default tier, login sets state cookie, callback happy path (mints JWT + upserts user), repeat-login preserves tier, state mismatch 400, missing cookie 400, unknown provider 404, unconfigured 503, no-email-from-provider 502
  • Full suite: 438 passing

GET /auth/oauth/{provider}/callback closes the OAuth dance:
  - verify state cookie vs query (400 on mismatch — CSRF anchor)
  - exchange authorization code for access token
  - fetch userinfo
  - upsert local user (preserve existing tier — P27's webhook owns it)
  - mint and return the same TokenResponse JWT the password endpoint
    returns

User.tier column (default "community") drives the billing feature
gates. Added with an idempotent ALTER TABLE migration in init_db so
legacy DBs stay read-compatible. JWT payload now carries tier;
/auth/me and UserRead expose it.

10 new tests cover migration, register default tier, callback happy
path, repeat-login tier preservation, state mismatch / missing cookie
400s, unknown provider 404, unconfigured 503, no-email 502. Full
suite: 438 passing.
@harsh-pandhe harsh-pandhe merged commit 2b1e0d7 into main May 24, 2026
2 checks passed
@harsh-pandhe harsh-pandhe deleted the feat/p26-oauth-callback branch May 24, 2026 06:36
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