From fe104c2364de35bcdb2a10ca469cd25c12b04289 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 16 Feb 2026 08:45:37 -0800 Subject: Prevent duplicate Ark vault accounts Co-Authored-By: Claude Opus 4.6 --- src/routes/(app)/account/ark/+page.server.ts | 10 ++++++++++ src/routes/(app)/account/new/+page.server.ts | 7 +++++++ src/routes/(app)/account/new/+page.svelte | 22 +++++++++++++--------- 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 src/routes/(app)/account/ark/+page.server.ts create mode 100644 src/routes/(app)/account/new/+page.server.ts (limited to 'src') diff --git a/src/routes/(app)/account/ark/+page.server.ts b/src/routes/(app)/account/ark/+page.server.ts new file mode 100644 index 00000000..90e617ff --- /dev/null +++ b/src/routes/(app)/account/ark/+page.server.ts @@ -0,0 +1,10 @@ +import { auth, get } from "$lib/utils"; +import { redirect } from "@sveltejs/kit"; + +export async function load({ cookies, parent }) { + const { user } = await parent(); + const accounts = await get("/accounts", auth(cookies)); + if (accounts.some((a) => a.type === "ark")) { + redirect(307, `/${user.username}`); + } +} diff --git a/src/routes/(app)/account/new/+page.server.ts b/src/routes/(app)/account/new/+page.server.ts new file mode 100644 index 00000000..8ecbb61c --- /dev/null +++ b/src/routes/(app)/account/new/+page.server.ts @@ -0,0 +1,7 @@ +import { auth, get } from "$lib/utils"; + +export async function load({ cookies }) { + const accounts = await get("/accounts", auth(cookies)); + const hasArk = accounts.some((a) => a.type === "ark"); + return { hasArk }; +} diff --git a/src/routes/(app)/account/new/+page.svelte b/src/routes/(app)/account/new/+page.svelte index c4045db8..3adb9d28 100644 --- a/src/routes/(app)/account/new/+page.svelte +++ b/src/routes/(app)/account/new/+page.svelte @@ -1,5 +1,7 @@
@@ -17,16 +19,18 @@
- - -- cgit v1.2.3