Firebase Cloud Function - Create user with extra information

北城余情 提交于 2021-02-11 13:56:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!