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.
This commit is contained in:
1 parent
a66a3a4b6a
commit
f0a9661f8e
24 files changed
+5214
-173
No files matched your search
@@ -52,6 +52,27 @@ export async function saveSettings(
|
||||
});
|
||||
}
|
||||
|
||||
/** Unlinks Discord (members keep their username and password). */
|
||||
export async function unlinkDiscord(_: ActionState, _form: FormData): Promise<ActionState> {
|
||||
return attempt(async () => {
|
||||
unwrap(await api.account.discord.delete());
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
/** A basic account (Discord only) becomes a member: a username and password. */
|
||||
export async function finishSetup(_: ActionState, form: FormData): Promise<ActionState> {
|
||||
// Passwords aren't trimmed.
|
||||
const password = typeof form.get("password") === "string" ? (form.get("password") as string) : "";
|
||||
if (password !== form.get("password2")) return { error: "The passwords don't match." };
|
||||
const state = await attempt(async () => {
|
||||
unwrap(await api.account.finish.post({ username: field(form, "username"), password }));
|
||||
});
|
||||
if (state?.error) return state;
|
||||
revalidatePath("/", "layout");
|
||||
redirect("/account?welcome=1");
|
||||
}
|
||||
|
||||
export async function signOutComputers(_: ActionState, _form: FormData): Promise<ActionState> {
|
||||
return attempt(async () => {
|
||||
unwrap(await api.account["signout-computers"].post());
|
||||
|
||||
Reference in new issue
Block a user