AuthService handleAuthentication does not redirect unless timeout is given

I am implementing the latest version of auth0 in my angular2 app. The issue i am facing is that the navigation from callback does not happen till i provide a timeout as below:

public handleAuthentication(): void {
    this.auth0.parseHash((err, authResult) => {
      if (authResult && authResult.accessToken && authResult.idToken) {
        window.location.hash = '';
        this.setSession(authResult);
        setTimeout(()=>{
            this.router.navigate('/apic','dashboard']);
        },50)
        
      } else if (err) {
        this.router.navigate('/']);
        console.log(err);
      }
    });
  }

I have called this in the appcomponent as suggested in help articles.
Can you please suggest, what going wrong here?

The scenario you described seems to be highly specific to the client application so without a sample application that reproduces the issue it is very difficult to guess the root cause (unless you already experienced something similar, which I haven’t).

My suggestion would be to try to replicate the issue with the smallest sample code you can, that way you would be able to share all the code that replicates the issue. Another alternative would be to start removing stuff from the application (commenting any code you can) until the issue no longer manifests.

I have seen similar behaviour.
In my case it kept redirecting back to the callback component.
Not sure the exact circumstances but I will keep looking.

I have seen similar behaviour.
In my case it kept redirecting back to the callback component.
Not sure the exact circumstances but I will keep looking.

1 Like