FIREBASE phoneAuth ( LinkWithPhoneNumber ) . How to change a user's linked phone number later in Firebase Web. ( nodejs, Create-react-app )?

五迷三道 提交于 2019-12-13 03:15:43

问题


I am using firebase in my create-react-app project. For SignUp purpose I am using firebaseAuth().createUserWithEmailAndPassword(email, password)

Then after SignUp I am saving their phoneNumber in localStorage and redirect them to PhoneAuth page using then I am using this function

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) {
    })
}

After the recaptcha and all done I get the I successfully linked the user's email with their phoneNumber. But how to update that phoneNumber later ? I couldn't find anything regarding updating a linked phoneNumber in the docs.


回答1:


There's an updatePhoneNumber method on the User object for that purpose.

See the reference docs and the documentation on updating a user's profile.

Note that you'll need a phoneCredential for this, meaning that this must be a verified phone number. See how to update user phone number in firebase.auth (js, ts).

If you want to update a user's phone number without verifying it, that can be done from the Admin SDK. For an example of this, see How to update phone number on Firebase Authentication in NodeJS?



来源:https://stackoverflow.com/questions/52647092/firebase-phoneauth-linkwithphonenumber-how-to-change-a-users-linked-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!