From 3808aaa8da95158ff88d4815a8a9416f552ff6e2 Mon Sep 17 00:00:00 2001 From: Omer Sabic Date: Fri, 7 Jun 2024 15:20:33 +0200 Subject: [PATCH] fa --- src/routes/auth.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/routes/auth.js b/src/routes/auth.js index 53ad80b..31ed592 100644 --- a/src/routes/auth.js +++ b/src/routes/auth.js @@ -64,6 +64,7 @@ export const authRoutes = (fastify, _, done) => { } let session_id; let existing_session = await tx.select().from(sessions).where(eq(sessions.user_id, user.id)); + console.log("existing_session", existing_session); if (existing_session.length > 0) { let session_info = await createSession(user.id, { access_token: token.access_token, @@ -75,8 +76,9 @@ export const authRoutes = (fastify, _, done) => { } else { let session_info = await tx.select().from(users).leftJoin(sessions, eq(sessions.user_id, users.id)).where(eq(users.google_id, user_info.id)); - if (session_info.length == 0) { + if (!session_info || session_info.length == 0) { response.status(400).send({ success: false, message: "Problem when creating user account" }); + await tx.rollback(); return; } console.log("session_info", session_info);