I'm a bit confused about some interesting behavior I've noticed while working with Firebase. Although I never used the older version, I believe getRedirectResult is a newer feature since they partnered with Google.
Currently, I am using Vue.js along with vue-router and Firebase for my single page application (SPA). The app has a landing page as well as another view where users can be logged in or not. Login is achieved through redirection. Upon loading this second view, I check getRedirectResult in the 'activate' hook of vue-router. If there is a user, I perform further actions based on the user information.
The issue arises as follows:
- We are on the second page. The user logs in and getRedirectResult successfully finds the user.
- The user then logs out and we return to the landing page.
- When we click on a button that takes us back to the second page, getRedirectResult still remembers the previous user. How is this possible?
I couldn't find information on whether I am missing something and need an additional check, or if I should somehow force a page refresh after logout to erase the memory of the last logged-in user. Is this a bug or am I overlooking something? Any help would be greatly appreciated!
Here is the code snippet for calling getRedirectResult on the second page within the vue component router's 'activate' hook:
firebase.auth().getRedirectResult()
.then((result) => {
return result.user;
}).then((user) => {
// Perform necessary actions.
});
Update: This issue was resolved by performing a hard page refresh in the logout callback, like so:
firebase.auth().signOut()
.then(() => {window.location.href = '/'});