From e0f5c70f85456297ff9b235c6aeab9746a054f6c Mon Sep 17 00:00:00 2001 From: Linnnus Date: Tue, 18 Feb 2025 18:02:23 +0100 Subject: Use abstract client interface for DB interactions --- app/src/lib/server/sessions.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/src/lib/server/sessions.ts') diff --git a/app/src/lib/server/sessions.ts b/app/src/lib/server/sessions.ts index 1b829ff..0ca46e0 100644 --- a/app/src/lib/server/sessions.ts +++ b/app/src/lib/server/sessions.ts @@ -51,7 +51,7 @@ function encodeBase32LowerCaseNoPadding(input: Uint8Array): string { const VALID_MILLISECONDS = 1000 * 60 * 60 * 24 * 30; /** Creates a new session for the user with the given `userId`. */ -export async function createSession(dbConn: pg.PoolClient, userId: number): Promise { +export async function createSession(dbConn: pg.ClientBase, userId: number): Promise { const token = generateSessionToken(); const session: Session = { token: token, @@ -78,7 +78,7 @@ export async function createSession(dbConn: pg.PoolClient, userId: number): Prom * @returns A session + user pair if the session is valid, or `null` for both otherwise. */ export async function validateSessionToken( - dbConn: pg.PoolClient, + dbConn: pg.ClientBase, token: string, ): Promise { // Step 1 @@ -129,13 +129,13 @@ export async function validateSessionToken( /** Invalidates the session with token `sessionToken`. */ export async function invalidateSession( - dbConn: pg.PoolClient, + dbConn: pg.ClientBase, sessionToken: string, ): Promise { await dbConn.query("DELETE sessions WHERE token = ?;", [sessionToken]); } /** Invalidates all sessions for the user with the id `userId`. */ -export async function invalidateAllSessions(dbConn: pg.PoolClient, userId: number): Promise { +export async function invalidateAllSessions(dbConn: pg.ClientBase, userId: number): Promise { await dbConn.query("DELETE sessions WHERE user_id = ?", [userId]); } -- cgit v1.2.3