fix: sign up with existing account email bug (#517)

* fix: sign up with existing account email bug
This commit is contained in:
Anjy Gupta
2023-10-05 15:29:43 +05:30
committed by GitHub
parent eac7aa84b0
commit 49d55227e8

View File

@ -12,12 +12,16 @@ export const authRouter = router({
return await createUser({ name, email, password, signature });
} catch (err) {
console.error(err);
let message =
'We were unable to create your account. Please review the information you provided and try again.';
if (err instanceof Error && err.message === 'User already exists') {
message = 'User with this email already exists. Please use a different email address.';
}
throw new TRPCError({
code: 'BAD_REQUEST',
message:
'We were unable to create your account. Please review the information you provided and try again.',
message,
});
}
}),