Skip to content

Commit

Permalink
fixed issue with login page being accessible after login (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmit-coder committed Dec 12, 2023
1 parent 84e97e8 commit 5d1d3f8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/routes/(auth)/login/+page.server.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit 5d1d3f8

Please sign in to comment.