简体   繁体   中英

How to handle Auth variable mechanism while using firebase Nodejs client

I am using Firebase Node.js client and every function is inside Node.js index.js file.

My user function firebase.auth().signInWithEmailAndPassword(email, password) is also inside index.js file of Node.js.

If I am authenticating first user and then second and then third and so on, then I am not able to persist the auth variable for users as it is overwriting with one another.

I went through the Firebase docs they are using client side JavaScript authentication codes but I do not want to use client visible codes as I have to write the other database transaction codes inside JavaScript itself if I use JavaScript authentication.

I want to do authentication through Node.js itself and then allow persist the auth variable to use for security rules.

Appreciate your help. I am trying since three weeks but it is not happening for me.

You are using a client side library and it seems like you are misunderstanding how the Firebase Authentication works. The authentication backend is handled by Firebase itself and you have nothing that needs to be done on your side, except using their Client libraries depending on what platform you are.

One of the key benefit of using Firebase Auth is not to have to handle the user auth in the backend by yourself, and I strongly suggest you to read the documentation again: https://firebase.google.com/docs/auth

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM