Reputation: 1785
Firstly I create new user in firebase using function createUserWithEmailAndPassword([email protected], password)
.
I then sign in using Facebook using the code below
const result = await LoginManager.logInWithPermissions(['public_profile', 'email']);
const data = await AccessToken.getCurrentAccessToken();
const firebaseCredential = await auth.FacebookAuthProvider.credential(data.accessToken);
const fbUserObj = await auth().signInWithCredential(firebaseCredential);
Problem is that it creates a completely seperate user account with seperate UID....even though the email address linked to the facebook account is the same one that was used to createUserWithEmailAndPassword
.
How do I make it so user can log into exising account using Facebook?
Upvotes: 1
Views: 586
Reputation: 599031
When you call auth().signInWithCredential(firebaseCredential)
, you're indeed creating a new account in Firebase Authentication.
If you instead want to link the Facebook credentials to an existing account, you need to call linkWithPopup
or linkWithRedirect
as shown in the Firebase documentation on linking accounts.
Upvotes: 3