如何从链接帐户时的'auth/credential-already-in-use'错误中恢复



遵循本指南: https://firebase.google.com/docs/auth/web/account-linking 在我的网络应用程序中,我可以毫无问题地将两个帐户合并为一个帐户, 但是当我尝试在我的移动应用程序中执行相同的操作时:

//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())
})
});
})

prevUser.linkAndRetrieveDataWithCredential的执行 失败,错误代码:"身份验证/无当前用户" 我找不到此错误的文档。所以我的问题是,当我想合并 react-native-firebase 中的现有帐户时,如何从身份验证/凭据已在使用的错误中恢复?

提前感谢!

对此感到抱歉 - 由于我在 GitHub 上的此问题评论中描述的困难,我们不得不放弃对错误对象凭据的支持。

但是,我们计划最早作为 v5.0.0版本的一部分实现,或者最迟在 v5.1.0 版本中实现。

订阅上面链接的问题,我将在支持登陆时更新并关闭它。

相关内容

最新更新