简体   繁体   English

如何使用Firebase身份验证登录用户

[英]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.

相关问题 nodejs 上的 Firebase 身份验证,如何登录用户并使用 mongodb? - Firebase Authentication on nodejs, how to login a user and use mongodb? 将用户导入 Firebase 身份验证后无法登录 - Unable to login after importing user into Firebase Authentication reactjs 中的登录功能使用 firebase 身份验证 - Login functionality in reactjs using the firebase authentication 如何使用 firebase 认证重新认证用户? - how to reauthenticate user with firebase authentication? 如何使用Firebase刷新令牌保留用户身份验证? - How do I persist user authentication using the Firebase refresh token? 如何在vue js项目中检测用户的firebase身份验证登录状态? - How to detect the user's firebase authentication login status in a vue js project? 如何使用Firebase Simple Login for Facebook处理用户信息 - How to handle user information using firebase simple login for facebook Firebase 身份验证检测用户是否来自重定向登录 - Firebase Authentication detect if user came from redirect login 使用firebase认证和firestore添加用户 - Using firebase authentication and firestore to add user 用户使用Firebase身份验证登录后如何重定向? - How to redirect after a user signs in with Firebase authentication?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM