【发布时间】:2020-12-07 13:49:45
【问题描述】:
✅我可以让用户使用verifyPhoneNumber 更新他们的手机号码并更新currentUser.updatePhoneNumber
❌ 当我允许通过电话登录时,我的问题出现了,并且 新用户 尝试使用电话号码登录,帐户会自动创建。
如果我随后需要将号码与电子邮件帐户关联,上述方法将返回credential-already-in-use 错误。
Firebase 在其documentation 中推荐以下方法。
var credential = firebase.auth.PhoneAuthProvider.credential(confirmationResult.verificationId, code);
firebase.auth().signInWithCredential(credential);
所以我一起做了这个linkWithCredential 但是,signInWithCredential 返回一个带有result.credential = null的结果
// Sign in user with the account you want to link to
auth.signInWithCredential(credential).then(function(result) {
console.log("Sign In Success", result);
var currentUser = result.user;
return prevUser.linkWithCredential(result.credential) //this line doesn't work.
.then(function(linkResult) {
return auth.signInWithCredential(linkResult.credential);
})
}).catch(function(error) {
console.log("Sign In Error", error);
});
由于 result.credential = null,我无法继续使用 LinkWithCredential。
我也试过linkWithPhoneNumber,但它返回一个验证ID,我仍然无法合并帐户。
❓请问你们是如何将 phoneNumber 帐户与其他帐户(Facebook/google/email)合并的?
【问题讨论】:
-
看我的问题
标签: javascript reactjs firebase firebase-authentication