From dc9c6281b86ddb5d5300ad4b3c75155ea436581d Mon Sep 17 00:00:00 2001 From: EETagent Date: Sat, 3 Dec 2022 17:14:06 +0100 Subject: [PATCH] feat: redirect to dashboard if logged in --- .../routes/(candidate)/auth/login/+layout.server.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 frontend/src/routes/(candidate)/auth/login/+layout.server.ts diff --git a/frontend/src/routes/(candidate)/auth/login/+layout.server.ts b/frontend/src/routes/(candidate)/auth/login/+layout.server.ts new file mode 100644 index 0000000..9198de9 --- /dev/null +++ b/frontend/src/routes/(candidate)/auth/login/+layout.server.ts @@ -0,0 +1,11 @@ +import type { LayoutServerLoad } from './$types'; + +import { redirect } from '@sveltejs/kit'; + +export const load: LayoutServerLoad = ({ cookies }) => { + const isAuthenticated = cookies.get('id'); + + if (isAuthenticated) { + throw redirect(302, '/dashboard'); + } +};