From 2261379ba4988457e072ba0ce8eb2a1eee86bee2 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 2 Jun 2026 18:31:06 -0700 Subject: [PATCH 1/2] fix(auth): show "account already exists" on duplicate email signup --- apps/sim/lib/auth/auth.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/sim/lib/auth/auth.ts b/apps/sim/lib/auth/auth.ts index 40037c938c..9517bbb909 100644 --- a/apps/sim/lib/auth/auth.ts +++ b/apps/sim/lib/auth/auth.ts @@ -844,6 +844,22 @@ export const auth = betterAuth({ } } + if (ctx.path.startsWith('/sign-up/email') && ctx.body?.email) { + const signupEmail = ctx.body.email.toLowerCase() + const [existingUser] = await db + .select({ id: schema.user.id }) + .from(schema.user) + .where(eq(schema.user.email, signupEmail)) + .limit(1) + + if (existingUser) { + throw new APIError('UNPROCESSABLE_ENTITY', { + message: 'User already exists', + code: 'USER_ALREADY_EXISTS', + }) + } + } + return }), }, From cc005e5c2e89160a341119b9ebfd069e92fd1a42 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 2 Jun 2026 18:46:50 -0700 Subject: [PATCH 2/2] fix(auth): use exact path match for duplicate-email signup check --- apps/sim/lib/auth/auth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sim/lib/auth/auth.ts b/apps/sim/lib/auth/auth.ts index 9517bbb909..76465b45be 100644 --- a/apps/sim/lib/auth/auth.ts +++ b/apps/sim/lib/auth/auth.ts @@ -844,7 +844,7 @@ export const auth = betterAuth({ } } - if (ctx.path.startsWith('/sign-up/email') && ctx.body?.email) { + if (ctx.path === '/sign-up/email' && ctx.body?.email) { const signupEmail = ctx.body.email.toLowerCase() const [existingUser] = await db .select({ id: schema.user.id })