Bilal Shah
Bilal Shah

Reputation: 1265

Delete other firebase authentication account and link that key to new authentication account

I have two methods for signing in, email and password, and phone number. When I register using a phone number I create an account. Now I create another account with email. Upon updating the email account Profile I added a phone number that already exists in a different account. How can I delete that phone number account and linked that phone number to my current email account?

Upvotes: 0

Views: 222

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 138899

Since you say that you have two methods for signing in, a single user can create two accounts, one with a phone number, and one with an email and password. In this case, it really depends on which one would you like to be used as a primary authentication option. For example, if you want the phone authentication to be the primary option, once the user is authenticated, you can get the credentials as explained in the official documentation on how to create a PhoneAuthCredential object, and then simply call FirebaseUser's linkWithCredential(AuthCredential credential) method to link with email and password, for example. However, you can link that account with any other available providers, like Google or Facebook.

If you need by chance a custom authentication system, then you should consider implementing this mechanism:

https://firebase.google.com/docs/auth/android/custom-auth

So there is no need to delete any account, simply link it.

Upvotes: 1

Related Questions