Web Firebase Auth: Force signout without waiting for onAuthStateChanged?

65 views
Skip to first unread message

Stephen Evans

unread,
Jul 23, 2020, 2:15:23 PM7/23/20
to Firebase Google Group
Hello,  I have a "reset" route which completely removes the state of my app from the user's browser.  I'd like it to be more-or less instant.  

Currently though, when they navigate to that route, I first have to initialize firebase then wait for onAuthStateChanged to tell me if a user was logged in, and if so log them out.  Then finally I can clear my app's locally stored data.

Is there a cross-browser safe way to immediately turf all firebase auth persistence without waiting, assuming firebase hasn't even been initialised yet?

Thanks!  

Rachel Myers

unread,
Jul 23, 2020, 3:24:35 PM7/23/20
to fireba...@googlegroups.com
Auth is writing to local storage; you could modify local storage directly without using the SDK. 

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/313be4f8-adf3-4c0a-9c62-c9861f63399fn%40googlegroups.com.

Stephen Evans

unread,
Jul 23, 2020, 6:56:15 PM7/23/20
to Firebase Google Group
Thanks for the help.

On Chrome it seems to be using indexDB.  I worry that it depends on the browser capabilities that it detects, and so it might not be safe unless I really knew all the possibilities.  Would be nice if there was a "static" api method for clearing auth persistence that didn't require firebase to be initialised.  

Reply all
Reply to author
Forward
0 new messages