Skip to content

feat: support invite code redemption via SSO registration #226

@ctkm-aelf

Description

@ctkm-aelf

Problem

SSO registration (GitHub/Google) does not support invite codes. When INVITE_CODE_REQUIRED is enabled, users who try to register via SSO are blocked because there is no mechanism to pass an invite code through the OAuth flow.

Email registration works correctly — the invite code field is present and validated. But SSO has no equivalent path, meaning new users cannot create an account via SSO when invite codes are required.

This is an M0 blocker — external developer users will default to GitHub SSO.

Current behavior

  1. User enters invite code on registration page
  2. User clicks "Sign up with GitHub/Google"
  3. OAuth redirect happens — invite code is lost (not passed through)
  4. Callback returns — backend rejects with SocialAuthRegistrationClosed because no invite code
  5. User cannot register

Expected behavior

  1. User enters invite code on registration page
  2. User clicks "Sign up with GitHub/Google"
  3. Invite code is passed through the OAuth flow
  4. Callback validates and consumes the invite code
  5. User account is created and linked to the invite code

Implementation

Backend (social_auth.rs)

  • Accept invite_code query param on GET /api/v1/auth/social/{provider}
  • Validate code exists and is not exhausted before redirecting to provider
  • Store validated code in a signed cookie (same pattern as SOCIAL_STATE_COOKIE)
  • On callback, read invite code from cookie → consume it → create user with invite_code_id
  • Update allow_new_users logic: allow new user creation when a valid invite code cookie is present

Frontend (social-login-buttons.tsx + register-form.tsx)

  • Pass invite code value from the registration form to SocialLoginButtons component
  • Append ?invite_code={code} to the OAuth authorize URL

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions