问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/51260206/firebase-cloud-function-create-user-with-extra-information