Skip to content

Commit 2261379

Browse files
committed
fix(auth): show "account already exists" on duplicate email signup
1 parent 12db7da commit 2261379

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

apps/sim/lib/auth/auth.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,22 @@ export const auth = betterAuth({
844844
}
845845
}
846846

847+
if (ctx.path.startsWith('/sign-up/email') && ctx.body?.email) {
848+
const signupEmail = ctx.body.email.toLowerCase()
849+
const [existingUser] = await db
850+
.select({ id: schema.user.id })
851+
.from(schema.user)
852+
.where(eq(schema.user.email, signupEmail))
853+
.limit(1)
854+
855+
if (existingUser) {
856+
throw new APIError('UNPROCESSABLE_ENTITY', {
857+
message: 'User already exists',
858+
code: 'USER_ALREADY_EXISTS',
859+
})
860+
}
861+
}
862+
847863
return
848864
}),
849865
},

0 commit comments

Comments
 (0)