fix issues
This commit is contained in:
@@ -6,7 +6,8 @@ import type { Logger } from '@core/shared/application';
|
||||
import { tryGetHttpRequestContext } from '@adapters/http/RequestContext';
|
||||
|
||||
const COOKIE_NAME = 'gp_session';
|
||||
const SESSION_TTL_MS = 3600 * 1000;
|
||||
const SESSION_TTL_MS = 3600 * 1000; // 1 hour
|
||||
const REMEMBER_ME_TTL_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
|
||||
|
||||
type StoredSession = AuthSession;
|
||||
|
||||
@@ -82,9 +83,10 @@ export class CookieIdentitySessionAdapter implements IdentitySessionPort {
|
||||
return session;
|
||||
}
|
||||
|
||||
async createSession(user: AuthenticatedUser): Promise<AuthSession> {
|
||||
async createSession(user: AuthenticatedUser, options?: { rememberMe?: boolean }): Promise<AuthSession> {
|
||||
const issuedAt = Date.now();
|
||||
const expiresAt = issuedAt + SESSION_TTL_MS;
|
||||
const ttlMs = options?.rememberMe ? REMEMBER_ME_TTL_MS : SESSION_TTL_MS;
|
||||
const expiresAt = issuedAt + ttlMs;
|
||||
|
||||
const token = `gp_${randomUUID()}`;
|
||||
|
||||
@@ -102,7 +104,7 @@ export class CookieIdentitySessionAdapter implements IdentitySessionPort {
|
||||
const setCookie = buildSetCookieHeader({
|
||||
name: COOKIE_NAME,
|
||||
value: token,
|
||||
maxAgeSeconds: Math.floor(SESSION_TTL_MS / 1000),
|
||||
maxAgeSeconds: Math.floor(ttlMs / 1000),
|
||||
httpOnly: true,
|
||||
sameSite: 'Lax',
|
||||
secure: false,
|
||||
|
||||
Reference in New Issue
Block a user