Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Check for user exists before merging (#1626)

Luke Vella8a192f74a172
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([