alyssaxuu / mapus

A map tool with real-time collaboration 🗺️

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When I refresh the page, I log out

dislazy opened this issue · comments

When I refresh the page, I log out, which feels that the experience is not very good

Hmm, this could be due to this. I noticed there seems to be some inconsistencies where sometimes it will keep you logged in on refresh, and sometimes not. It appears it could have something to do with a delay when loading firebase, it might check when it's not ready yet. You could try increasing the timeout there to see if it works. Ultimately I'm not sure what the fix would be, I'd have to look into it further.

Hmm, this could be due to this. I noticed there seems to be some inconsistencies where sometimes it will keep you logged in on refresh, and sometimes not. It appears it could have something to do with a delay when loading firebase, it might check when it's not ready yet. You could try increasing the timeout there to see if it works. Ultimately I'm not sure what the fix would be, I'd have to look into it further.

Okay, thank you very much, I wonder if it is possible to store the session in localstorage

commented

I think this is caused by this line:

// Make sure the session persists after closing the window so the user doesn't have to log in every time
firebase.auth().setPersistence(firebase.auth.Auth.Persistence.SESSION)

In the firebase docs, firebase.auth.Auth.Persistence.SESSION is described as

Indicates that the state will only persist in the current session or tab, and will be cleared when the tab or window in which the user authenticated is closed

I think firebase.auth.Auth.Persistence.LOCAL is the right setting:

Indicates that the state will be persisted even when the browser window is closed or the activity is destroyed in React Native. An explicit sign out is needed to clear that state. Note that Firebase Auth web sessions are single host origin and will be persisted for a single domain only

I've created a pull request with this change here: #5

ezoic increase your site revenue