-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
blocked: react-nativeIssue or PR blocked by a React Native issue or change.Issue or PR blocked by a React Native issue or change.impact: web-implementationAn API in RNFB does not conform to the Firebase Web SDKAn API in RNFB does not conform to the Firebase Web SDKplugin: authenticationFirebase AuthenticationFirebase Authenticationresolution: duplicate
Description
following this guide: https://firebase.google.com/docs/auth/web/account-linking In my web app I was able to merge two accounts into one with no problem, but when I try to do the same in my mobile app:
//action to recover from the auth/credential-already-in-use
// Get reference to the currently signed-in user
const { currentUser } = firebase.auth();
var prevUser = currentUser;
// Sign in user with another account
firebase.auth().signInAndRetrieveDataWithCredential(linkError.credential).then((userCredential) => {
console.log("Sign In Success", userCredential.user);
var newUser = userCredential.user;
// Merge prevUser and newUser data stored in Firebase.
// Note: How you handle this is specific to your application
// After data is migrated delete the duplicate user
return newUser.delete().then(() => {
// Link the OAuth Credential to original account
return prevUser.linkAndRetrieveDataWithCredential(linkError.credential);
}).then(() => {
// Sign in with the newly linked credential
return firebase.auth().signInAndRetrieveDataWithCredential(linkError.credential).then(() => {
return dispatch(mergeAccountsCompleted())
})
});
})The execution of prevUser.linkAndRetrieveDataWithCredential fails with the error code: 'auth/no-current-user' I couldn't find documentation for this error. So my question is, how can I recover from the auth/credential-already-in-use error when I want to merge the existing accounts in react-native-firebase ?
Thanks in advance !
Metadata
Metadata
Assignees
Labels
blocked: react-nativeIssue or PR blocked by a React Native issue or change.Issue or PR blocked by a React Native issue or change.impact: web-implementationAn API in RNFB does not conform to the Firebase Web SDKAn API in RNFB does not conform to the Firebase Web SDKplugin: authenticationFirebase AuthenticationFirebase Authenticationresolution: duplicate