Files
t5de-hub/apps/web/lib/discord.ts
T
dhkatz f0a9661f8e
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 and basic accounts
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.
2026-11-19 01:11:51 -08:00

16 lines
1016 B
TypeScript

// What went wrong with Discord sign-in or linking, as a sentence. Better Auth sends people back with ?error=<code>.
const messages: Record<string, string> = {
email_not_verified: "Your Discord account's email isn't verified. Verify it in Discord, then try again.",
email_not_found: "Your Discord account has no email. Add one in Discord and verify it, then try again.",
account_not_linked:
"This email belongs to a T5DE account. Sign in to it with your username and password, then link Discord from your account page.",
account_already_linked_to_different_user: "That Discord account already signs in to another T5DE account.",
access_denied: "Discord sign-in was cancelled.",
};
/** The sentence for an error Discord sign-in came back with (undefined if there's none). */
export function discordError(code: string | string[] | undefined): string | undefined {
if (typeof code !== "string" || !code) return undefined;
return messages[code] ?? "Signing in with Discord didn't work. Try again.";
}