[英]How to add or update phone_number in Firebase Auth
I am trying to add a phone number when a user is signing up using Firebase Auth.当用户使用 Firebase 身份验证注册时,我尝试添加电话号码。 I am using this method:我正在使用这种方法:
user = firebase.auth().createUserWithEmailAndPassword('myemail@email.com', 'password').catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
And I am trying to update mobile number during the signup process using:我正在尝试使用以下方法在注册过程中更新手机号码:
if(user){
user.updatePhoneNumber("+91999999999")
}
I am getting error:我收到错误:
updatePhoneNumber failed: First argument "phoneCredential" must be a valid phone credential.
I know it needs to be a valid phone number and according to this Answer we need to verify phone number to update.我知道它需要是一个有效的电话号码,根据这个答案,我们需要验证电话号码才能更新。
So my question is I need to create a signup form where I am getting phone email and PWD.所以我的问题是我需要创建一个注册表单,我可以在其中接收电话电子邮件和 PWD。
I want to save phone number and verify the number later.我想保存电话号码并稍后验证该号码。 Is there any way we can update phone number during signup.有什么办法可以在注册期间更新电话号码。
Using this code I can update phone_number in firebase admin:使用此代码,我可以在 firebase admin 中更新 phone_number:
user = auth.create_user(
email='user@example.com',
email_verified=False,
phone_number='+15555550100',
password='secretPassword',
display_name='John Doe',
photo_url='http://www.example.com/12345678/photo.png',
disabled=False)
Why there is no function like this in web signup.为什么网络注册中没有这样的功能。
There is no way to set a phone number for a user without signing them in with/verifying that number.如果不使用该号码登录/验证用户,则无法为用户设置电话号码。 You will have to sign in the user with phone authentication too, and then link the two providers together .您还必须使用电话身份验证登录用户,然后将两个提供商链接在一起。
If you don't want to sign the user in with their phone number, but merely want to store that number, you will have to do so outside of Firebase Authentication's built-in phone number provider.如果您不想让用户使用他们的电话号码登录,而只想存储该号码,则必须在 Firebase 身份验证的内置电话号码提供程序之外执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.