Solution 1 :
I am not sure whether phone auth (OTP) in Flutter can be used to create a user along with their details in Firestore. Or whether it can only used for user authentication.
Sign-ins using Firebase Authentication only create a user account that’s visible within the Firebase Auth product. It has nothing to do with Firestore. This is true for all type of authentication with Firebase Auth.
If you want to add user details to a document in Firestore, you’re going to have to write code to do that.
Solution 2 :
This is a bad response – the original poster is asking if it is possible to create a new FirebaseAuth record using just the Phone + OTP process, and not using the createUserWithEmailAndPassword call, not how to store custom user data in Firestore
Problem :
What I am trying to achieve is:
- An app that does not require email id at all for registration/signup, or login.
- Registration page that requires user to fill their name, phone number and a few other details.
- When user presses send OTP on the registration page, the number gets verified and a user profile is created in Firestore, and his details are saved.
- If the user logs out, on login page user must be able to enter phone number, get OTP sent again, and be logged in into the same account.
Issue:
I am not sure whether phone auth (OTP) in Flutter can be used to create a user along with their details in Firestore. Or whether it can only used for user authentication.
If it is possible to use phone number (OTP) auth to create user profile in Firestore in Flutter, please help.
Most tutorials I referred to, only show how phone authentication can be done using OTP, but do not cover creating a profile using the same.
Comments
Comment posted by Amethyst
I’m new to flutter, so please help me out here… To add user details using email and password from my signup to Firestore document, I’d use
Comment posted by Doug Stevenson
createUserWithEmailAndPassword does not do anything with Firestore. It only creates a user account in Firebase Authentication. I suggest following the documentation for phone auth if you’re having problems setting that up. No matter how you sign in the user, adding a document to Firestore will be a completely different task.
Comment posted by Amethyst
Ohkay…I’ll do that…Thanks a lot! 🙂