Skip to content

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

🐛 Fix issue where space creation fails when creating an account from a social login

Luke Vella482d499278bb
diff --git a/apps/web/src/lib/auth.ts b/apps/web/src/lib/auth.ts
index 0b1123a54..baec8ba41 100644
--- a/apps/web/src/lib/auth.ts
+++ b/apps/web/src/lib/auth.ts
@@ -223,8 +223,17 @@ export const authLib = betterAuth({
user: {
create: {
after: async (user) => {
- // create a space for the user
- await createSpace({ name: "Personal", ownerId: user.id });
+ // check if user exists in prisma
+ const existingUser = await prisma.user.findUnique({
+ where: {
+ id: user.id,
+ },
+ });
+
+ if (existingUser) {
+ // create a space for the user
+ await createSpace({ name: "Personal", ownerId: user.id });
+ }
posthog?.capture({
distinctId: user.id,