question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

logout doesn't log out of auth0 if current url has a path

See original GitHub issue

I have a logout button on my site, and when it’s clicked I’m calling the following:

logout() {
    // Ensure Auth0 client instance exists
    this.auth0Client$.subscribe((client: Auth0Client) => {
      // Call method to log out
      client.logout({
        client_id: environment.clientID,
        returnTo: `${window.location.origin}`
      });
    });
  }

If I’m on the root of my app (ie. no URL path), then it correctly signs me out of Auth0 as well my app. In Fiddler I can see that the /v2/logout request is made to Auth0. All’s good here.

However, if I’m on a page of my app, and click the logout button which calls the above code - it tries to do the redirect without calling the /v2/logout endpoint.

I’m not sure why this would be the case. I can’t find anything in my app that would differentiate like this.

What was the expected behavior?

It to logout of Auth0 regardless of what page/url the user is in.

Reproduction

I haven’t tried to create a cutdown version of the app, as this would take time. I’ll try this next if the above isn’t enough info though. I’m sure I must be doing something daft!

Environment

Please provide the following:

  • Version of auth0-spa-js used: 1.13.5
  • Which browsers have you tested in? Chrome
  • Which framework are you using, if applicable (Angular, React, etc): Angular
  • Other modules/plugins/libraries that might be involved:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dracancommented, Dec 22, 2020

Ah thanks - I’ll change that to a button.

Yeah - I’m not sure (can’t remember) why I didn’t initially use your Angular library. I don’t want to change it now though, as it works.

1reaction
dracancommented, Dec 21, 2020

@frederikprijck Thanks - it’ll take some time for me to come up with a reproducible case that I can share, and it’ll be in the new year now. I’ll add it to my list for when I start back. It sounds like there’s no obvious reason why that method call would do one thing for one URL and another for the root URL though. I’ll do a bit more digging after the xmas break, and reply back here if I find anything (or manage to create a reproducable case that I can share).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Logout - Auth0
Log users out of Auth0 by clearing the Single Sign-on (SSO) cookie. Identity Provider Session Layer: The last session layer is the identity...
Read more >
Logout does not log user out - Auth0 Community
The link works, goes to the /out.html page, but when I type into url: /home (or any other @requires_auth page) I am able...
Read more >
Redirect Users After Logout - Auth0
To add a list of URLs that the user may be redirected to after logging out at the tenant level, go to the...
Read more >
Logout is not working for logout google in IOS
I'm using the Single Page Application SDK. I can successfully log in to the application with the Auth0 Universal login, but when trying...
Read more >
Check Login and Logout Issues - Auth0
Can you test login another way to ensure credentials are correct? · If password expiration is a possibility, check if password has expired....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found