Login possible fix and something else I can't remember

This commit is contained in:
2026-06-26 19:39:45 +02:00
parent 46a3216386
commit 1b5f244f28
6 changed files with 54 additions and 33 deletions
+2 -23
View File
@@ -9,7 +9,7 @@ if (!RAW_SECRET) {
}
const JWT_SECRET = new TextEncoder().encode(RAW_SECRET);
const SESSION_COOKIE = "session";
export const SESSION_COOKIE = "session";
const MAX_FAILED_ATTEMPTS = 5;
const LOCKOUT_DURATION_MINUTES = 15;
@@ -195,28 +195,7 @@ export function mapDbUserToSessionUser(
}
export async function createSession(userId: string, role: string) {
const token = await signToken({ userId, role });
const cookieStore = await cookies();
cookieStore.set(SESSION_COOKIE, token, {
httpOnly: true,
secure: process.env.NODE_ENV === "production",
sameSite: "strict",
path: "/",
});
return token;
}
export async function destroySession() {
const cookieStore = await cookies();
cookieStore.set(SESSION_COOKIE, "", {
httpOnly: true,
secure: process.env.NODE_ENV === "production",
sameSite: "strict",
path: "/",
maxAge: 0,
});
return signToken({ userId, role });
}
export async function encryptPassword(password: string): Promise<string> {