When an user signs up on my site, I call firebase.auth().createUserWithEmailAndPassword(email, password) and their user has successfully been created.
I basically want a "Do I have an account" on my page. If they enter their e-mail address, it should send a request to Firebase with ONLY their e-mail, and Firebase should then return with true/false (or something similar).
A "workaround" I have found is trying to create an user or simply signing into Firebase with an empty password. I assume Firebase would return "wrong password" (meaning they have an account). firebase.auth().fetchProvidersForEmail("[email protected]") could also work, but I haven't been able to figure out how it works.
Alternatively I store all emails in an array. Push to that array when a new user signs up, but that seems very insecure and like a lot of work (as I don't think you can just push an email and forget the ID, basically making it impossible to iterate through all emails).
Here's what I have come up with that works:
firebase.auth().signInWithEmailAndPassword(this.username, " ").catch(function(error) { if(error.code === "auth/wrong-password") { console.log("USER HAS AN ACCOUNT"); } else if(error.code === "auth/user-not-found"){ console.log("NEW USER"); } }); Simply sign in with a password that doesn't work.