fix: try to properly set cookie expiration

This commit is contained in:
Andy Burke 2025-10-03 13:38:33 -07:00
parent 8c5d81f293
commit dcbd9c7511

View file

@ -10,7 +10,7 @@ import { get_session, get_user, PRECHECK_TABLE, require_user, SESSION_ID_TOKEN,
import * as bcrypt from '@da/bcrypt'; import * as bcrypt from '@da/bcrypt';
import { verifyTotp } from '../../../utils/totp.ts'; import { verifyTotp } from '../../../utils/totp.ts';
const DEFAULT_SESSION_TIME: number = 28 * (24 * (60 * (60 * 1_000))); // 28 days const DEFAULT_SESSION_TIME: number = 365 * (24 * (60 * (60 * 1_000))); // 365 days
export const PRECHECKS: PRECHECK_TABLE = {}; export const PRECHECKS: PRECHECK_TABLE = {};
@ -186,7 +186,7 @@ const session_secret_buffer = new Uint8Array(20);
export async function create_new_session(session_settings: SESSION_INFO): Promise<SESSION_RESULT> { export async function create_new_session(session_settings: SESSION_INFO): Promise<SESSION_RESULT> {
const now = new Date().toISOString(); const now = new Date().toISOString();
const expires: string = session_settings.expires ?? const expires: string = session_settings.expires ??
new Date(new Date(now).valueOf() + DEFAULT_SESSION_TIME).toISOString(); new Date(new Date(now).valueOf() + DEFAULT_SESSION_TIME).toUTCString();
crypto.getRandomValues(session_secret_buffer); crypto.getRandomValues(session_secret_buffer);