How to fetch cached credential

Asked by At

My problem is the following:

When a user log in, with state persistence set to LOCAL then refresh the page. The firebase auth script automatically logs the user in.

This in it self is 100% okay. The problem is that there is no way for me to know if the user is currently BEING logged in.

Sure there is authState, getRedirectResult and others methods to detect the state CHANGE in the credential BUT: there is no way to know what is happening at the moment of the refresh. That being said, all those methods send no signal on refresh and only activate once the user actually log in 2 to 3 seconds after page refresh.

I need a method to actually get the status of the connection. So i can put a loader saying "loggin in" when a user credentials are in cache.


//im using this right now, this is good but it only activate once the //user is logged in.

  this.afAuth.authState.subscribe(
      res => {
        if (res) {

          console.log(this.fss.afs.createId())

          this.fss.simple_toast("connected, welcome " + res.displayName)

          this.fss.uid = res.uid

          //some logic there 


        } else {


          console.log("not connected")
          for (var proprety in this.obs) {
            this.obs[proprety].unsubscribe()
          }
          this.fss.uid = false

        }
      }
    )

what i need is something like this :


this.afAuth.getLogStatus()

// this might return : "credential located, loggin in" or " no //credential located" so i know what is going on.

Is it possible?

0 Answers