From 39918459abf83043fbe9d18400638df23e454153 Mon Sep 17 00:00:00 2001 From: Omer Sabic Date: Sat, 8 Jun 2024 15:12:39 +0200 Subject: [PATCH] tx --- src/routes/auth.js | 2 +- src/utils/token.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/auth.js b/src/routes/auth.js index 914e538..b0934a6 100644 --- a/src/routes/auth.js +++ b/src/routes/auth.js @@ -73,7 +73,7 @@ export const authRoutes = (fastify, _, done) => { access_token: token.access_token, refresh_token: token.refresh_token, expires_at: new Date(token.expires_at) - }); + }, tx); console.log("SESSION MADE") session_id = session_info.session_id; diff --git a/src/utils/token.js b/src/utils/token.js index 75f1089..93c4366 100644 --- a/src/utils/token.js +++ b/src/utils/token.js @@ -13,9 +13,9 @@ export async function createSession(user_id, { access_token, refresh_token, expires_at, -}) { +}, tx = db) { try { - const [existing_session] = await db.select().from(sessions).where(eq(sessions.user_id, user_id)); + const [existing_session] = await tx.select().from(sessions).where(eq(sessions.user_id, user_id)); if (existing_session) { return { @@ -23,7 +23,7 @@ export async function createSession(user_id, { } } - const token = await db.insert(sessions).values({ + const token = await tx.insert(sessions).values({ user_id, access_token: access_token, refresh_token: refresh_token,