what is the correct way to check if email exists
i see isUsernameAvailable - what about email. I was thinking to ask email of user first, if it exists, proceed to login page, otherwise proceed to sign up. It's not clear what is the cleanest way to check if email exists in our db.
5 Replies
when signup is called and email exists there is an error code for that as well
then u catch that error code and then redirect to sign in
@Better Auth what is the error code for when email exists?
Hi there! When a user attempts to sign up with an email that's already registered, Better Auth returns the error code
USER_ALREADY_EXISTS—and it now provides a more specific message: "User already exists. Use another email." [1][2]. Let me know if you have any other questions about Better Auth!
Sources:
[1] chore: Standardize error code capitalization and improve USER_ALREADY_EXISTS error code
[2] Client | Better AuthGitHub
chore: Standardize error code capitalization and improve USER_ALREA...
USER_ALREADY_EXISTS
This changes the USER_ALREADY_EXISTS error code from "User already exists" to "User already exists. Use another email." this signifies that t...
Client | Better Auth
Better Auth client library for authentication.
performing signup without intention of signing up is not ideal. any other way to do check if email exists?
you can just use the db directly for this, email is in users table so check if there is entry for that email
makes sense - thx!