Reputation: 1647
I've been trying to find a way to figure out if a user is already created with the same email in Firebase, and it doesn't seem like it is possible.
This basically means I will need to save the email for every user and check in the Firebase database if the email is there already.
Is there really no other way?
I see all these posts with... how to link a user with another auth provider, but there is no way to know if the user with the specific mail exists already...
Upvotes: 2
Views: 631
Reputation: 30808
You cannot link an existing account to another account. You can only link a new account to an existing one. If you wish to check if an email of a new account already exists before either creating it or linking it to the existing account. You can call https://firebase.google.com/docs/reference/js/firebase.auth.Auth#fetchProvidersForEmail If the email provided already exists, it will return an array of the provider ids. You then sign in the user to the existing account and link the new account to it. fetchProvidersForEmail will work as expected when multiple accounts per email is disabled in Firebase Console(default behavior unless you are migrating from Firebase v2).
Upvotes: 1