[英]How to login a user using firebase authentication
I'm currently using firebase-admin
to create a web Dashboard with node.js
as a backend which will have multiple users and those users have user specific data in my database, note that I need them to be able to delete or add stuff to the database as well, I've managed to add new users to Autentication
using firebase.auth().createUser()
programmatically, but how would one go about logging in a user, and then from there controlling which uid
is logged in and displaying his data (giving him access to the correct data, obviously don't want him messing with someone elses data). 我目前正在使用
firebase-admin
创建一个以node.js
作为后端的Web仪表板,该仪表板将有多个用户,并且这些用户在我的数据库中具有用户特定的数据,请注意,我需要他们能够删除或向其中添加内容同样在数据库中,我设法以编程方式使用firebase.auth().createUser()
将新用户添加到Autentication
,但是如何登录用户,然后从那里控制登录并显示哪个uid
他的数据(允许他访问正确的数据,显然不希望他弄乱别人的数据)。
I know this might seem like a really newbie question, and it probably is, but firebase docs always get me confused for some reason. 我知道这似乎是一个真正的新手问题,也许是,但由于某些原因,firebase文档总是让我感到困惑。 Any tips?
有小费吗? I'd greatly appreciate.
我将不胜感激。
Any questions don't hesitate. 如有任何疑问,请不要犹豫。
To login a new user, try this: 要登录新用户,请尝试以下操作:
firebase.auth().signInWithEmailAndPassword(email, password)
this returns a Firebase.Promise
which you can use to track the operation progress. 这将返回一个
Firebase.Promise
,可用于跟踪操作进度。 If successful, it will return the corresponding Firebase.User
object. 如果成功,它将返回相应的
Firebase.User
对象。
From there, the logged-in user will also be available in the firebase.auth().currentUser
property. 从那里,登录用户也将在
firebase.auth().currentUser
属性中可用。 You can then use the user's uid
property as a key for his JSON branch on the database. 然后,您可以将用户的
uid
属性用作其数据库上JSON分支的键。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.