mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-12 21:08:46 +00:00
세션 쿠키를 계속 롤링하도록 개선하여 세션이 유효함에도 브라우저에서 쿠키가 삭제되던 문제 해결
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { error, redirect, type Handle } from "@sveltejs/kit";
|
||||
import env from "$lib/server/loadenv";
|
||||
import { authenticate, AuthenticationError } from "$lib/server/modules/auth";
|
||||
|
||||
export const authenticateMiddleware: Handle = async ({ event, resolve }) => {
|
||||
@@ -15,6 +16,12 @@ export const authenticateMiddleware: Handle = async ({ event, resolve }) => {
|
||||
|
||||
const { ip, userAgent } = event.locals;
|
||||
event.locals.session = await authenticate(sessionIdSigned, ip, userAgent);
|
||||
event.cookies.set("sessionId", sessionIdSigned, {
|
||||
path: "/",
|
||||
maxAge: env.session.exp / 1000,
|
||||
secure: true,
|
||||
sameSite: "strict",
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof AuthenticationError) {
|
||||
if (pathname === "/auth/login") {
|
||||
|
||||
Reference in New Issue
Block a user