skip to Main Content

I’m using a Firebase phone auth as primary authentication. Since the phone is vulnerable, I want to link an email address to it that the user can use to access his account to change his phone number in case he lost his phone or got stolen. I can’t find a way how to do it.
I saw a method currentUser.linkWithPhoneNumber(). However, reading its documentation, it says it is only supported on web platforms. Is there any other way to make this possible?

2

Answers


  1. Chosen as BEST ANSWER

    upon further reading, i found Email Link Authentication that answered everything i've asked.

    Linking/re-authentication with email link You can also link this method of authentication to an existing user. For example a user previously authenticated with another provider, such as a phone number, can add this method of sign-in to their existing account.

    https://firebase.google.com/docs/auth/flutter/email-link-auth


  2. When you authenticate a user with a phone number, the only data that you have inside the FirebaseUser object when the authentication completes, are the UID and the phone number. If you need to add an email address to an existing account, you can request the user to provide an email address. Once you have that, you can update the email address using the FirebaseUser#updateEmail(String email) function. As soon as the account is updated, you can add any functionality related to that email address.

    Since you didn’t specify a programming language, I linked that function to the Android docs, but certainly, you can do the same thing in the case of any other programming languages.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search