fix(api): 🐛 Error out on registration when email is already taken

This commit is contained in:
Jesse Wierzbinski 2024-04-28 14:09:34 -10:00
parent 065b37f091
commit 2ea5612759
No known key found for this signature in database

View file

@ -166,6 +166,13 @@ export default apiRoute<typeof meta, typeof schema>(
description: "is from a blocked email provider", description: "is from a blocked email provider",
}); });
// Check if email is taken
if (await User.fromSql(eq(Users.email, body.email)))
errors.details.email.push({
error: "ERR_TAKEN",
description: "is already taken",
});
// Check if agreement is accepted // Check if agreement is accepted
if (!body.agreement) if (!body.agreement)
errors.details.agreement.push({ errors.details.agreement.push({