I'm a little confused by some behaviour I'm seeing with Firebase. I never used the old version, but I believe getRedirectResult is new since they joined forces with Google.
I have a SPA that I am using Vue.js with vue-router, and Firebase for. There is a landing page, and then another view for which users can be logged in, or not. Login is done by redirect. When this second view is loaded, I check getRedirectResult in the vue-router 'activate' hook, and if there is a user, do some other stuff with the user information.
The problem proceeds thusly:
- We are on second page. User logs in. getRedirectResult is called and finds a user. Yay.
- User logs out. We are back on landing page.
- We click a button that leads us to second page. getRedirectResult is called and finds the previous user. What?! No!
I can't find anything on whether I am missing something and need some kind of extra check in place, or to somehow forcibly refresh the page after logout so it forgets that the last user logged in, or if this would be considered a bug. Any assistance would be greatly appreciated!
getRedirectResult call on second page in vue component router 'activate' hook:
firebase.auth().getRedirectResult()
.then((result) => {
return result.user;
}).then((user) => {
// Do stuff.
});
Update: Solved by doing a hard page refresh in the logout callback, as follows:
firebase.auth().signOut()
.then(() => {window.location.href = '/'});
/login- madsongr