From 8a1d2454681001dc01b2d61b05f5c82625c6a360 Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 12 Nov 2023 17:51:47 -0500 Subject: [PATCH] redirect away from create form if account has name --- src/routes/profile/create/+page.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/routes/profile/create/+page.ts diff --git a/src/routes/profile/create/+page.ts b/src/routes/profile/create/+page.ts new file mode 100644 index 0000000..69b13a9 --- /dev/null +++ b/src/routes/profile/create/+page.ts @@ -0,0 +1,10 @@ +import {redirect} from '@sveltejs/kit'; +import type {PageLoad} from './$types'; + +export const load: PageLoad = async ({parent, url}) => { + // the user has already done initial setup - go back to the normal profile + const parentData = await parent(); + if (parentData.user && parentData.user.name) { + throw redirect(302, '/profile'); + } +};