make session cookie name a variable
All checks were successful
delpoy / build-and-deploy (push) Successful in 27s

This commit is contained in:
2023-08-29 14:52:27 +02:00
parent dd2c10a365
commit ccc022f5f0
4 changed files with 10 additions and 8 deletions

View File

@ -3,6 +3,8 @@ import type { Cookies } from '@sveltejs/kit';
import * as crypto from 'crypto';
import type { Admin } from '$lib/server/database';
export const sessionCookieName = 'craftattack_sess';
export interface Session {
sessionId: string;
userId: number;
@ -17,7 +19,7 @@ function sessionFromId(sessionId: string | Cookies): Session | null {
}
function sessionIdFromStringOrCookies(input: string | Cookies): string | null {
return typeof input == 'string' ? input : input.get('session') || null;
return typeof input == 'string' ? input : input.get(sessionCookieName) || null;
}
export function addSession(user: { id: number; permissions: Permissions } | Admin): string {