在我的创建-反应-应用程序项目中,我使用了firebase。为了SignUp的目的,我使用firebaseAuth().createUserWithEmailAndPassword(email, password)
然后,在SignUp之后,我将它们的phoneNumber保存在localStorage中,并使用localStorage将它们重定向到PhoneAuth页面,然后使用此函数
export function PhnAuth(phone) {
window.recaptchaVerifier = new firebaseAuth.RecaptchaVerifier('recaptcha-container',{'size': 'small'});
return firebaseAuth().currentUser.linkWithPhoneNumber(phone, window.recaptchaVerifier)
.then(function (confirmationResult) {
window.confirmationResult = confirmationResult;
}).catch(function (error) {
})
}
在完成了recaptcha之后,我成功地将用户的电子邮件与他们的phoneNumber链接起来。但是以后如何更新phoneNumber呢?我找不到任何关于更新文档中的链接phoneNumber的内容。
发布于 2018-10-04 06:37:55
为此,在updatePhoneNumber
对象上有一个User
方法。
请参阅参考文档和关于更新用户配置文件的文档。
请注意,为此您需要一个phoneCredential
,这意味着这必须是一个经过验证的电话号码。见如何在firebase.auth (js,ts)中更新用户电话号码。
如果您想要更新用户的电话号码而不进行验证,可以通过Admin完成。有关此问题的示例,请参见如何在NodeJS的Firebase身份验证中更新电话号码?
发布于 2020-03-10 01:22:40
您需要解除当前手机(provider.providerId === 'phone')
的链接,然后您可以链接一个新的
const currentUser = firebaseAuth().currentUser;
currentUser.unlink('phone').then(successCallback).catch(errorCallback)
若要检查电话是否链接到当前用户,需要检查提供商列表。
const phoneProviders = currentUser.providerData.filter(
provider => provider.providerId === 'phone'
);
if (phoneProviders.length > 0) {
currentUser.unlink('phone').then(successCallback).catch(errorCallback);
}
https://stackoverflow.com/questions/52647092
复制相似问题