Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error merging two existing accounts #1385

Closed
ygomezfinale opened this issue Aug 10, 2018 · 2 comments
Closed

Error merging two existing accounts #1385

ygomezfinale opened this issue Aug 10, 2018 · 2 comments
Assignees
Labels
blocked: react-native Issue or PR blocked by a React Native issue or change. impact: web-implementation An API in RNFB does not conform to the Firebase Web SDK plugin: authentication Firebase Authentication resolution: duplicate

Comments

@ygomezfinale
Copy link

ygomezfinale commented Aug 10, 2018

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 !

@Salakar
Copy link
Member

Salakar commented Sep 1, 2018

@ygomezfinale we don't yet support error.credential, please see this issue: #1329

In short; waiting on a PR to land in React Native - once/if this lands in a version we can start getting this supported.

PR: facebook/react-native#20940


Loving react-native-firebase and the support we provide? Please consider supporting us with any of the below:

@Salakar Salakar closed this as completed Sep 1, 2018
@Salakar Salakar added resolution: duplicate blocked: react-native Issue or PR blocked by a React Native issue or change. plugin: authentication Firebase Authentication impact: web-implementation An API in RNFB does not conform to the Firebase Web SDK labels Sep 1, 2018
@Salakar Salakar self-assigned this Sep 1, 2018
@ygomezfinale
Copy link
Author

Hello Salakar,
this issue is not about the support of error.credential, the problem here is the prevUser seems to be not logged in when executing prevUser.linkAndRetrieveDataWithCredential, it launch the 'auth/no-current-user' error code, my question is about how to handle this:
When linking two existing accounts, without logged out the current user, log in with the second user, delete it and linking this second account to the first one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: react-native Issue or PR blocked by a React Native issue or change. impact: web-implementation An API in RNFB does not conform to the Firebase Web SDK plugin: authentication Firebase Authentication resolution: duplicate
Projects
None yet
Development

No branches or pull requests

2 participants