0

but firebaseStore.auth() is defined, and I enabled the password signin for the store. onAuthStateChanged seems just disappeared.

I tried to execute this before the route gets established as well as in a router call after passing the firebase instance into it.

I wonder what else I can do further to debug this?

I found this article Firebase Admin SDK - Current Logged In User - Nodejs But it did not help me to resolve the issue.

ey dee ey em
  • 7,991
  • 14
  • 65
  • 121
  • Are you trying to use [firebase.auth().onAuthStateChanged()](https://firebase.google.com/docs/reference/node/firebase.auth.Auth#onAuthStateChanged)? – Bob Snyder Nov 19 '17 at 02:07
  • I wrote why there isn't `onAuthStateChanged` below. But it seems very much like a [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). What are you trying to do that requires the concept of a "current user"? It might help if you [create an MCVE](http://stackoverflow.com/help/mcve), so that we can see what you're trying to accomplish and where you are stuck. – Frank van Puffelen Nov 19 '17 at 02:38
  • @BobSnyder yes, I tried to use that on server side, because I want to just pass the user name and passwords to server and call onAuthStateChanged() to check if the user is valid, at all time. I realized it is a wrong approach.... I was trying to avoid loading firebase on the front end – ey dee ey em Nov 19 '17 at 14:23

1 Answers1

0

The Firebase Admin SDK runs as an (unidentified) administrative user. It does not have the concept of a "current user" and thus does not implement onAuthStateChanged.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Ok, that's more clear now. So basically firebase has to run in the client side to identify logged in user. I was trying to run in the server side, so the client wont know all my keys and such.... is it necessary to hide my keys though? the one that I suppose to copy to client to initate the firebase app... or maybe I dont have to? – ey dee ey em Nov 19 '17 at 11:35
  • The values that Firebase tells you to put into your web page are just configuration data. See https://stackoverflow.com/questions/37482366/is-it-safe-to-expose-firebase-apikey-to-the-public – Frank van Puffelen Nov 19 '17 at 16:03