[英]I want to create a user registration from react and firebase
Im working in a project and im using react and firebase for that.我在一个项目中工作,我为此使用了 react 和 firebase。 I want to create a user registration, I can use firebase authentication with google or facebook.
我想创建一个用户注册,我可以使用 firebase 身份验证与 google 或 facebook。 but thats not what I want.
但这不是我想要的。 I want to take many data from the user and let that data appear on their profile.
我想从用户那里获取许多数据,并让这些数据出现在他们的个人资料中。 so can I do that with react and firebase.
所以我可以用 react 和 firebase 做到这一点。 ?
? can we use firebase as a database to store users data?
我们可以使用 firebase 作为数据库来存储用户数据吗?
An user have an UID (unique id) when he logs in to your app.用户在登录您的应用程序时拥有一个 UID(唯一 ID)。 You can store the uid in the database and then link other infos to it.
您可以将 uid 存储在数据库中,然后将其他信息链接到它。 You can get it with
firebase.auth().currentUser.uid
您可以使用
firebase.auth().currentUser.uid
获得它
Take a look atthe official documentation看看官方文档
What I usually do is creating a "profiles" collection.我通常做的是创建一个“配置文件”集合。 A profile document's ID is the User ID and contains more data ie email.
配置文件的 ID 是用户 ID,包含更多数据,即 email。 I create the profile document after the firebase auth register function is done and I have the register user object.
我在 firebase 身份验证寄存器 function 完成后创建配置文件文档,并且我有注册用户 object。
You can also put that logic in a cloud function if you need security.如果您需要安全性,您还可以将该逻辑放在云 function 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.