Closed thomasorten closed 6 years ago
Noticed it too, but I'm wondering if this is a change in Firease's API.
I'm preparing a new version, with a lot of breaking changes, which will allow any schema. Will add more examples too.
@sidferreira @thomasorten This is how I solved the problem.
https://gist.github.com/ejferg/c025e202868da4761e737446166579c6
@ejferg Thanks a lot man! I think today I'll be able to check this and other stuff and update the tool.
@sidferreira I noticed that this worked for the 1st refresh but not for the 2nd, since auth
is null
.
will take a look!
@sidferreira I think this may have been my mistake, just mentioning it so that you don't lose time (I had some custom code there).
@sidferreira I am afraid I still have the problem, auth is null
. I notice that this happens in every hot reloading
when I develop the app and when I am in a route that needs to get data and therefore uses the if (type === AUTH_CHECK) {
code.
It is interesting that the logout does not happen if I just move to the "Dashboard" route before I make a change in the code and then go to the page that fetches data. In this case, the auth
is retained.
I think I found something. It has to do with the timeout in this line:
const timeout = (!firebase.auth().currentUser && localStorage.getItem(config.localStorageTokenName)) ? 1000 : 100
It appears that if I increase the 1000
value to 4000
then I am not forced to logout.
Which means that hot reloading
needs a little more time than the normal production
run?
I did the following change for DEV only and it works (in a hacky way):
const timeout = (!firebase.auth().currentUser && localStorage.getItem(config.localStorageTokenName)) ? (process.env.NODE_ENV !== 'production' ? 4000 : 1000) : 100
I also made a PR here: https://github.com/sidferreira/aor-firebase-client/pull/30
This happens in v0.3.1. Login works fine and close the tab, open new tab requires me to login again.
Well, I had to change firebase auth persistence storage to local from session. https://firebase.google.com/docs/auth/web/auth-state-persistence
I can't get the user to persist.
I can login fine, but upon browser refresh, firebase.auth().currentUser is null. The token firebaseToken is set in localStorage.
Everything else is pretty similar to your demo.
And, how is data structured in firebase? E.g. from your demo?