Ad

Is It Possible For Firebase Auth To Validate Email And Password Without Creating A New User?

firebase.createUserWithEmailAndPassword(email, password) also validates the email & password and returns an error if the email format is invalid, or if it already exists, or if the password is invalid, etc.

However, Firebase doesn't seem to have a function that does only the validation. If the email and password are valid, it directly creates a new user.

Is there any way Firebase can be used to do validation? I did write code for it, but it is not only redundant, I also cannot determine if an email already exists without using Firebase.

Ad

Answer

If you want to check if an email address is already associated with an account in Firebase Authentication, you can call the fetchSignInMethodsForEmail method.

If that returns an empty list, the email address is not in use yet.

Conveniently, it will also throw an exception of the email address it not correctly formatted.

Ad
source: stackoverflow.com
Ad