Having a bit of an issue currently. I have a user management system set up where you can log in and etc using firebase. Currently we have the firebase persistence set to local so you are able to open new tabs and still be logged in on the new tab. However I have a use case where I want to log out a user once all tabs are closed.
Case 1: User logs in, opens new tab is logged in on both tabs
Case 2: User logs out new tab and is still logged in on original tab (Also close original and be logged in on new tab)
Case 3: User closes all tabs or closes browser. When going back to the web app they should be logged out
I have tried firebase persistence set to session however this does not allow for new tabs as you will be logged out when opening a new tab.
Any ideas or suggestions on a method on getting around this?
Thank you
Did you tried to use localStorage to store like a counter of opened tabs. While closing if this counter is 1, do a callback before closing (for ex in hooks, on the useState, return is called while component is destroying), then erase the local storage, call the API to revoke the token ?