0

Im triying to use firebase in my app but I have a doubt about registration process, I declared an User collection, but when I sign up with google or facebook, the data is stored in Authentication, I want create an user but besides the fiels email and password, also with a fields like address, role, city and use the createUserWithEmailAndPassword method , to create the user with all those fields, is there a way to do that?

  • 1
    Yes, you can write code to create a document in Firestore when a user signs in for the first time. Are you having a problem with that? – Doug Stevenson Dec 09 '19 at 20:22
  • You'll have to write your own code to do that. See https://stackoverflow.com/q/46657445 for a list of links (many of them for Realtime Database, but they can easily be ported to Cloud Firestore). – Frank van Puffelen Dec 09 '19 at 21:41

1 Answers1

1

Auth only creates it's own entry to its own table. so you should first get these details from the user and send them to user collection manually.

You can create a new user object adding all these details into it and call this:

this.fireStore.collection("users")
      .doc(user.id)
      .set(user);

Due to security reasons, I wouldn't recommend storing the password in the db though.

Fulya D.
  • 592
  • 4
  • 9