Context
Supabase authentication, the local User record, role selection, and role-specific Grantee/PayoutProvider records are created through separate requests and hooks. Retries, simultaneous tabs, or callback failures can leave partial identities and conflicting onboarding state.
Scope
- Define an explicit onboarding state model independent of inferred missing rows.
- Make local identity upsert idempotent across email/password and OAuth callbacks.
- Provision the selected role and role-specific record atomically.
- Prevent unauthorized role changes and define the supported role-change workflow.
- Handle email changes, provider linking, duplicate verified emails, and disabled users deliberately.
- Replace duplicated client initialization checks with one server-authoritative bootstrap endpoint.
Acceptance criteria
Relevant areas
OAuth verification/register routes, role-selection provider/hooks, auth context/services, User, Grantee, and PayoutProvider models.
Context
Supabase authentication, the local
Userrecord, role selection, and role-specificGrantee/PayoutProviderrecords are created through separate requests and hooks. Retries, simultaneous tabs, or callback failures can leave partial identities and conflicting onboarding state.Scope
Acceptance criteria
Relevant areas
OAuth verification/register routes, role-selection provider/hooks, auth context/services,
User,Grantee, andPayoutProvidermodels.