From 5d1d3f80739b8f5d84efc627178d23780ae0fb3c Mon Sep 17 00:00:00 2001 From: Ashmit Jagtap Date: Tue, 12 Dec 2023 22:56:19 +0530 Subject: [PATCH] fixed issue with login page being accessible after login (#36) --- src/routes/(auth)/login/+page.server.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/routes/(auth)/login/+page.server.ts b/src/routes/(auth)/login/+page.server.ts index 0b46029..f62e6d3 100644 --- a/src/routes/(auth)/login/+page.server.ts +++ b/src/routes/(auth)/login/+page.server.ts @@ -1,10 +1,15 @@ -import type { Actions } from './$types'; +import type { Actions,PageServerLoad } from './$types'; import { fail, redirect } from '@sveltejs/kit'; import prisma from '@db'; import { hashPassword } from '$lib/crypto'; import { nanoid } from 'nanoid'; import { env } from '$env/dynamic/private'; +import { getUserIdFromCookie } from '$lib/server/auth'; +export const load:PageServerLoad = async({cookies})=>{ + const userId = await getUserIdFromCookie(cookies); + if (userId) throw redirect(303, '/'); +} export const actions: Actions = { default: async ({ cookies, request }) => { const data = await request.formData();