lol bad redirect code
This commit is contained in:
parent
5b838e0dfa
commit
d48ddbc91c
1 changed files with 3 additions and 3 deletions
|
|
@ -5,18 +5,18 @@ import { prisma } from '../prisma';
|
||||||
export async function validateSession(event: ServerLoadEvent) {
|
export async function validateSession(event: ServerLoadEvent) {
|
||||||
const sessionId = event.cookies.get('auth_session');
|
const sessionId = event.cookies.get('auth_session');
|
||||||
if (!sessionId) {
|
if (!sessionId) {
|
||||||
redirect(300, '/login');
|
redirect(302, '/login');
|
||||||
}
|
}
|
||||||
const session = await prisma.session.findUnique({
|
const session = await prisma.session.findUnique({
|
||||||
where: { id: sessionId },
|
where: { id: sessionId },
|
||||||
include: { user: true },
|
include: { user: true },
|
||||||
});
|
});
|
||||||
if (!session || !session.user) {
|
if (!session || !session.user) {
|
||||||
redirect(300, '/login');
|
redirect(302, '/login');
|
||||||
}
|
}
|
||||||
const expiry = session.expiresAt;
|
const expiry = session.expiresAt;
|
||||||
if (dayjs(expiry).isBefore(dayjs())) {
|
if (dayjs(expiry).isBefore(dayjs())) {
|
||||||
redirect(300, '/login');
|
redirect(302, '/login');
|
||||||
}
|
}
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue