Discord sign-in and basic accounts
Pull request / title (pull_request) Successful in 1s
CI / test (pull_request) Successful in 1m28s
CI / image (apps/api/Dockerfile, t5de-hub-api) (pull_request) Skipped
CI / image (apps/web/Dockerfile, t5de-hub-web) (pull_request) Skipped

Discord sign-in makes a basic account (Discord's verified email, no username
or password) for T5DE's other sites; it finishes setting up with a username
and password to use the hub. Implicit linking by email is off; members link
Discord from their account page. Better Auth 1.7.26.
This commit is contained in:
dhkatz committed 2026-11-19 01:11:51 -08:00
1 parent a66a3a4b6a
commit f0a9661f8e
24 files changed
+5214 -173

No files matched your search

+9 -4
View File
@@ -13,7 +13,8 @@ tokens (`Authorization: Bearer t5de_pat_...`, docs/console.md): those work only
Errors are `{"error": "<code>", "message": "<text for people>"}` with a 4xx/5xx status; `message` can be shown as
is. Codes: `invalid`, `signed_out`, `forbidden`, `not_found`, `no_such_imvu_account`, `already_linked`,
`code_missing`, `expired`, `link_cap`, `rate_limited`, `imvu_unavailable`, `unknown_product`, `hosted_room`.
`code_missing`, `expired`, `link_cap`, `rate_limited`, `imvu_unavailable`, `unknown_product`, `hosted_room`,
`awaiting_approval`, `finish_setup`.
## Accounts (Better Auth)
@@ -22,9 +23,12 @@ is. Codes: `invalid`, `signed_out`, `forbidden`, `not_found`, `no_such_imvu_acco
| `POST /api/auth/sign-up/email` | `{email, password, name, username}`. Usernames 3-32 of `A-Za-z0-9_`; passwords 10-256 characters. The first account is an admin. With registration closed, the others wait for approval (`approved: false`): every route but `/me` answers 403 `awaiting_approval`, and the rest of the hub treats them as signed out. |
| `POST /api/auth/sign-in/username` | `{username, password}`. With two-factor sign-in on, it answers `{twoFactorRedirect: true, twoFactorMethods: ["totp"]}` and no session: then `POST /api/auth/two-factor/verify-totp` `{code}` (from the app) or `/verify-backup-code` `{code}` signs in. |
| `POST /api/auth/two-factor/enable` | `{password}` → `{totpURI, backupCodes}`; on once `POST /api/auth/two-factor/verify-totp` `{code}` confirms it. `/two-factor/disable` and `/two-factor/generate-backup-codes` take `{password}`. Sensitive permissions need it on (docs/console.md). `/api/auth/admin/*` answers 404. |
| `POST /api/auth/sign-in/social` | `{provider: "discord", callbackURL, errorCallbackURL}` → `{url}` (Discord's consent page), when Discord sign-in is on (`DISCORD_CLIENT_ID`, `DISCORD_CLIENT_SECRET`). Discord comes back to `/api/auth/callback/discord`, which sends the browser to `callbackURL`, or to `errorCallbackURL?error=<code>`. The first time, it makes a **basic account** (docs/music.md, Accounts): Discord's name and email, no username or password, `kind: "basic"`. Only a verified Discord email will do (`email_not_verified`, or `email_not_found` for Discord accounts without one), and accounts are never linked by matching email: a Discord account whose email belongs to another T5DE account ends with `account_not_linked`. Basic accounts sign in to T5DE's other sites; on the hub every route but `/me` and `/account/finish` answers 403 `finish_setup`. |
| `POST /api/auth/link-social` | (signed in) `{provider: "discord", callbackURL, errorCallbackURL}` → `{url}`: links Discord to this account (`account_already_linked_to_different_user` if that Discord account signs in to another one) |
| `POST /api/auth/sign-out` | |
| `GET /api/v1/me` | `{person}` (`approved` false while waiting), with `picture`: the avatar picture of their first linked IMVU account (from IMVU, kept an hour), or `null`, `console`: whether the console is for them, and `unread`: their unread notifications |
| `GET /api/v1/hub` | (anyone) `{registration}`: `open` or `closed` |
| `GET /api/v1/me` | `{person}` (`approved` false while waiting; `kind`: `member` or `basic`), with `picture`: the avatar picture of their first linked IMVU account (from IMVU, kept an hour), or `null`, `console`: whether the console is for them, and `unread`: their unread notifications |
| `GET /api/v1/hub` | (anyone) `{registration, discord}`: registration `open` or `closed`, and whether Discord sign-in is on |
| `POST /api/v1/account/finish` | (a basic account) `{username, password}` → `{person}`: it becomes a member (`invalid_username`, `invalid_password`, `username_taken`, `already_member`); with registration closed it then waits for approval. Discord stays linked. |
## Proxies
@@ -45,7 +49,8 @@ is. Codes: `invalid`, `signed_out`, `forbidden`, `not_found`, `no_such_imvu_acco
| `GET /api/v1/online` | (anyone) `{online}`: accounts showing they're online (moderators see all, with `hidden`) |
| `GET /api/v1/online/events` | (anyone) server-sent events: `online` with `{online}` now and on each change |
| `GET /api/v1/rooms` | (anyone) `{rooms}`: listed IMVU rooms of T5DE users, with the T5DE users in each now (AP rooms for adults only) |
| `GET /api/v1/account` | `{person, links, challenges, computers, canLink}` |
| `GET /api/v1/account` | `{person, discord, links, challenges, computers, canLink}`; `discord`: `{available, linked}` |
| `DELETE /api/v1/account/discord` | unlinks Discord (members keep their password) |
| `POST /api/v1/account/links` | `{username}` → 201 `{challenge}` (the tagline code) |
| `POST /api/v1/account/links/:imvu/check` | `{link, moved}` |
| `DELETE /api/v1/account/challenges/:imvu` | cancel linking |