From 8a192f74a17212cd243eaa1ac4f8d0026f97930e Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Mon, 10 Mar 2025 10:48:20 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Check=20for=20user=20exists=20be?= =?UTF-8?q?fore=20merging=20(#1626)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/auth/helpers/merge-user.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/web/src/auth/helpers/merge-user.ts b/apps/web/src/auth/helpers/merge-user.ts index 8835084d1..4cfab3bd5 100644 --- a/apps/web/src/auth/helpers/merge-user.ts +++ b/apps/web/src/auth/helpers/merge-user.ts @@ -6,6 +6,17 @@ export const mergeGuestsIntoUser = async ( userId: string, guestIds: string[], ) => { + const count = await prisma.user.count({ + where: { + id: userId, + }, + }); + + if (count === 0) { + console.warn(`User ${userId} not found`); + return; + } + try { await prisma.$transaction(async (tx) => { await Promise.all([