Files
t5de-hub/packages/db/drizzle/meta/_journal.json
T
dhkatz f05874f800
Release / release (push) Successful in 5s
CI / test (push) Successful in 7m39s
CI / image (apps/api/Dockerfile, t5de-hub-api) (push) Successful in 32s
CI / image (apps/web/Dockerfile, t5de-hub-web) (push) Successful in 22s
feat(accounts): Discord sign-in and basic accounts (#22)
First half of docs/music.md's phase 1 (Accounts): Discord sign-in and basic accounts. The OIDC provider (Music as a trusted client, the `imvu` scope) is the next PR.

**Discord sign-in** (on when `DISCORD_CLIENT_ID` and `DISCORD_CLIENT_SECRET` are set; Discord redirects to `<API_URL>/api/auth/callback/discord`):

- The first time, it makes a **basic account** (`user.kind = "basic"`): Discord's name and email, no username or password. Basic accounts are for T5DE's other sites (Music); on the hub, every route but `/me` and `/account/finish` answers 403 `finish_setup`, and the website shows "Finish Setting Up Your Account" in place of every page.
- Only a **verified** Discord email (`user.validateUserInfo`): `email_not_verified`, or `email_not_found` for Discord accounts without one.
- **Never linked by matching email** (`accountLinking.disableImplicitLinking`): a Discord account whose email belongs to another T5DE account ends with `account_not_linked`, and the sign-in page says to sign in and link Discord from Account.
- Basic accounts don't count toward "the first account is an admin".

**Finishing setup**: `POST /api/v1/account/finish {username, password}` adds a password sign-in and a username in one transaction and makes the account a member (waiting for approval if registration is closed). Discord stays linked.

**Members** link Discord from the Account page (`/api/auth/link-social`; `account_already_linked_to_different_user` if it belongs to another account; merging basic accounts into members is phase 5) and unlink it (`DELETE /api/v1/account/discord`, audited). The console tags basic accounts "Discord only".

First half of docs/music.md's phase 1 (Accounts): Discord sign-in and basic accounts. The OIDC provider (Music as a trusted client, the `imvu` scope) is the next PR.

**Discord sign-in** (on when `DISCORD_CLIENT_ID` and `DISCORD_CLIENT_SECRET` are set; Discord redirects to `<API_URL>/api/auth/callback/discord`):

- The first time, it makes a **basic account** (`user.kind = "basic"`): Discord's name and email, no username or password. Basic accounts are for T5DE's other sites (Music); on the hub, every route but `/me` and `/account/finish` answers 403 `finish_setup`, and the website shows "Finish Setting Up Your Account" in place of every page.
- Only a **verified** Discord email (`user.validateUserInfo`): `email_not_verified`, or `email_not_found` for Discord accounts without one.
- **Never linked by matching email** (`accountLinking.disableImplicitLinking`): a Discord account whose email belongs to another T5DE account ends with `account_not_linked`, and the sign-in page says to sign in and link Discord from Account.
- Basic accounts don't count toward "the first account is an admin".

**Finishing setup**: `POST /api/v1/account/finish {username, password}` adds a password sign-in and a username in one transaction and makes the account a member (waiting for approval if registration is closed). Discord stays linked.

**Members** link Discord from the Account page (`/api/auth/link-social`; `account_already_linked_to_different_user` if it belongs to another account; merging basic accounts into members is phase 5) and unlink it (`DELETE /api/v1/account/discord`, audited). The console tags basic accounts "Discord only".

Also: Better Auth 1.7.14 → 1.7.26 (the OAuth provider package in the next PR needs it); migration `0021_account_kind` (one column, default `member`).

Tests: `apps/api/test/discord.test.ts` runs Better Auth's real social sign-in and callback against a stand-in for Discord's token and profile endpoints (basic account, verified email only, no linking by email, finishing setup, closed registration, linking and unlinking). Full suite 68/68, `check-types` and `build` pass locally. The new pages (sign-in's Discord button, Finish Setting Up, the Discord card) aren't checked in a browser yet: that needs the Discord application, then staging.

Before deploying: a Discord application with both redirect URLs (prod and staging), and its ID and secret in the hub stacks' secrets (dhkatz/infra).
Also: Better Auth 1.7.14 → 1.7.26 (the OAuth provider package in the next PR needs it); migration `0021_account_kind` (one column, default `member`).

Tests: `apps/api/test/discord.test.ts` runs Better Auth's real social sign-in and callback against a stand-in for Discord's token and profile endpoints (basic account, verified email only, no linking by email, finishing setup, closed registration, linking and unlinking). Full suite 68/68, `check-types` and `build` pass locally. The new pages (sign-in's Discord button, Finish Setting Up, the Discord card) aren't checked in a browser yet: that needs the Discord application, then staging.

Before deploying: a Discord application with both redirect URLs (prod and staging), and its ID and secret in the hub stacks' secrets (dhkatz/infra).

Co-authored-by: dhkatz <[email protected]>
2026-11-19 09:50:40 +00:00

160 lines
3.1 KiB
JSON

{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1793273462704,
"tag": "0000_init",
"breakpoints": true
},
{
"idx": 1,
"version": "7",
"when": 1793277687785,
"tag": "0001_age_checks",
"breakpoints": true
},
{
"idx": 2,
"version": "7",
"when": 1793321456968,
"tag": "0002_rooms",
"breakpoints": true
},
{
"idx": 3,
"version": "7",
"when": 1793324955738,
"tag": "0003_products",
"breakpoints": true
},
{
"idx": 4,
"version": "7",
"when": 1793347080470,
"tag": "0004_parent_info",
"breakpoints": true
},
{
"idx": 5,
"version": "7",
"when": 1793355138984,
"tag": "0005_hosted_rooms",
"breakpoints": true
},
{
"idx": 6,
"version": "7",
"when": 1793357692630,
"tag": "0006_decorations",
"breakpoints": true
},
{
"idx": 7,
"version": "7",
"when": 1793364727935,
"tag": "0007_hosted_rooms_phase2",
"breakpoints": true
},
{
"idx": 8,
"version": "7",
"when": 1793372872749,
"tag": "0008_product_deletion",
"breakpoints": true
},
{
"idx": 9,
"version": "7",
"when": 1793707706030,
"tag": "0009_registration",
"breakpoints": true
},
{
"idx": 10,
"version": "7",
"when": 1793862017365,
"tag": "0010_catalog_management",
"breakpoints": true
},
{
"idx": 11,
"version": "7",
"when": 1793886718951,
"tag": "0011_product_info",
"breakpoints": true
},
{
"idx": 12,
"version": "7",
"when": 1793888724185,
"tag": "0012_cases",
"breakpoints": true
},
{
"idx": 13,
"version": "7",
"when": 1793917069600,
"tag": "0013_file_blocks",
"breakpoints": true
},
{
"idx": 14,
"version": "7",
"when": 1793918993367,
"tag": "0014_api_tokens",
"breakpoints": true
},
{
"idx": 15,
"version": "7",
"when": 1793934143730,
"tag": "0015_two_factor",
"breakpoints": true
},
{
"idx": 16,
"version": "7",
"when": 1793935614967,
"tag": "0016_imports",
"breakpoints": true
},
{
"idx": 17,
"version": "7",
"when": 1794073227716,
"tag": "0017_importer_accounts",
"breakpoints": true
},
{
"idx": 18,
"version": "7",
"when": 1794078168609,
"tag": "0018_recorded_grants",
"breakpoints": true
},
{
"idx": 19,
"version": "7",
"when": 1794092472616,
"tag": "0019_shop_listing",
"breakpoints": true
},
{
"idx": 20,
"version": "7",
"when": 1794150630963,
"tag": "0020_importer_signed_in",
"breakpoints": true
},
{
"idx": 21,
"version": "7",
"when": 1795079107938,
"tag": "0021_account_kind",
"breakpoints": true
}
]
}