Reputation: 5987
I have got the firebase.auth().signInWithPhoneNumber(number, appVerifier)
to work nicely, but realized something that I didn't before. As soon as you put in the sms verification code it creates a whole other user under the phone auth, which makes since.
What I want to do however is just allow my current email/password users to add a phone number and then before they sign in have to go through a process of getting a verification sms code and put it in and only then through the success block log that user in.
My current solution is to add the phone number to the email/password account. Go through the phone auth process and if successful log out the phone auth account and then log the email/password account in with the same phone number. This sounds like a bad idea in the long run however, so is there a sms verification without authentication in firebase?
Upvotes: 3
Views: 1685
Reputation: 785
What you can do is to link your email/password user with a phone number credential using linkWithPhoneNumber method of User. Check out the docs here: https://firebase.google.com/docs/auth/web/phone-auth Linking to a phone number credential requires the user to verify their phone number with SMS code.
Upvotes: 2
Reputation: 11326
That case does sound like a bad idea.
Unfortunately, Firebase doesn't yet provide SMS verifications without Phone Auth. You'll have to look for a different way to do that.
Upvotes: 1