Question about Firebase logout and account selection

237 views
Skip to first unread message

Questioning

unread,
Oct 31, 2022, 10:40:44 AM10/31/22
to Firebase Google Group
So I am using Firebase for a webapp and I am curious as to the intended usage of Firebase Auth as well as what to do in this particular scenarion.

When logging in for the first time the user is able to sign in to their google account / select an already signed in account. This is great.

When the user logs out (using the signout promise) and logs in again they are automatically logged back in to the previous user.

Is there any way to interupt this flow and allow the user to select their account again?

Tracy Hall

unread,
Oct 31, 2022, 12:49:33 PM10/31/22
to Firebase Google Group
It does sound like you are not actually successfully logging out the Firebase Auth.  I use Firebase Auth, on web - and the "previous user" only shows up when they have *not* signed out (there's an active cookie in the browser).  Either you are not making the correct call, or possibly not waiting for the promise to resolve.

When my users are signed out,they do have to sign in / choose account - my code does *not* prompt them with possible accounts (that would be a security link), although *Google* (when using Google as the sign-in) does remember and present the past-used logins, usually.

Questioning

unread,
Oct 31, 2022, 4:44:26 PM10/31/22
to Firebase Google Group
As these things go I have actually managed to fix this issue after asking the question, despite it being something I've thought about for some weeks. The answer lays here: https://groups.google.com/g/firebase-talk/c/gxBm0WKCuIY basically I needed to send the GoogleAuthProvider some extra parameters prompt: 'select_account', as google falls back to a default of autoselection.

To add.

Below is the way in which I am logging out, I don't think I'm doing anything wrong here but feel free to correct me if I'm wrong. I am using Google as the provider. 

public logout(redirect: boolean): void {
    signOut(this.auth).then((_result: any) => {
      localStorage.clear();
      sessionStorage.clear();
    });
  }

Reply all
Reply to author
Forward
0 new messages