Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Authentication connect Email with Phone

I am currently using Email and Phone number authentication using Firebase.

And i have 3 EditText for:

  • Email
  • Phone Number
  • Password

But the problem is when the user is done registering it obviously creates 2 instance of accounts, one for the Email and second for the Phone number.

I would like to link the Email and Phone number together as one account. Is there any way to do that?

like image 395
GGWP Avatar asked Jun 21 '17 13:06

GGWP


People also ask

How do I use Firebase authentication email?

If you haven't yet connected your app to your Firebase project, do so from the Firebase console. Enable Email/Password sign-in: In the Firebase console, open the Auth section. On the Sign in method tab, enable the Email/password sign-in method and click Save.

How do I add my phone number to Firebase authentication?

Create fictional phone numbers and verification codesIn the Firebase console, open the Authentication section. In the Sign in method tab, enable the Phone provider if you haven't already. Open the Phone numbers for testing accordion menu. Provide the phone number you want to test, for example: +1 650-555-3434.


Video Answer


1 Answers

Depending on whether you want to allow for signing in with either email or phone number, or if you want to allow for the Phone number to be used as a second factor, for sign in, there are different solutions.

If you just want to have the Phone number be a second way to sign in, you can link the credentials using the linkWithCredential method on your Firebase User. This way you can add as many ways to sign in, as you want. Firebase has a good guide on this.

If you want the phone number to be a second factor of authentication, you will need to have a custom auth provider, which does the second factor authentication. There is also a getting started guide on this, however the 2 Factor Authentication part itself would be up to you.

like image 191
Bernd Avatar answered Sep 28 '22 03:09

Bernd