Dennis Schiepers
Dennis Schiepers

Reputation: 137

Firebase Cloud Function - Create user with extra information

I am currently looking for the best way to create a user with additional information in a cloud function. The obvious possibility seems to create a trigger which creates a user document:

functions.auth.user().onCreate((user) => { /* Create user document in firestore with base information*/ });

And afterwards add the information to the created document. (Handle the promise)

But one way or another I don't feel really satisfied with this solution. I would rather do all this stuff in one go. Does someone have a better solution?

Upvotes: 0

Views: 830

Answers (1)

Diego P
Diego P

Reputation: 1758

If you want to save additional user data in firebase I would recommend to handle this in your front-end after the newly added user is registered.

In your front-end once the registration promise is fulfilled, get the userid and perform a database set for example in users/${userid} with the initial data you want to save.

Upvotes: 1

Related Questions