Auth0 Home Blog Docs

Log out in sample NodeJS app not working

nodejs
sample-project

#1

I installed the sample NodeJS app and configured it to run locally per the instructions. When I click “log in”, I can sign up/log in. After clicking “log out”, I’m back on the home screen, but if I click “log in” then, I’m shown the “user profile” page. Deleting the session cookie manually won’t help - it gets recreated automatically (though with a different value each time).

What am I doing wrong? Can anybody reproduce this behavior?


#2

Not very helpful but I was not able to reproduce this with the python sample app. After clicking log out, and then log in again, I had to do a full login.


#3

Thanks for the idea - I’ll try with the python app. If it works, at least I’ll know that the problem is not with Auth0 configuration (which I don’t think is the case, but why not try?).


#4

Hey @mbork!

Have you been able to get up and running with the Python sample?

Let me know if you need any further help!


#5

Yes, although not without problems (the docs are very, so to speak, Auth0-y, i.e., incomplete and scattered in a few places; more specifically, this page does not even mention that I have to set up the “allowed logout url”, rendering it basically useless as a “starting guide”). Finally I did manage that, and the python app behaves correctly.

I found this in the quickstart guide for NodeJS:

This tutorial implements logout by closing the local user session. After logging out, the user’s session in the Auth0 authentication server is still open. For other implementations, please refer to the logout documentation.

This might explain the problem. Still, it is very strange - a “quickstart” should imho show how to set up a minimal, but complete app. An app without a possibility of logging out is far from that.

Anyway, referring to the docs didn’t help much - I tried what was written there:

To force a logout, redirect the user to the following URL:

https://DOMAIN/v2/logout

but my problem persisted. More precisely, I changed the logout url in the layout.pug file:

         a(href="/user" ).w3-bar-item.w3-button Profile
-        a(id="qsLogoutBtn" href="/logout").w3-bar-item.w3-button Log Out
+        a(id="qsLogoutBtn" href="https://DOMAIN/v2/logout").w3-bar-item.w3-button Log Out
       else

After logout, the browser now says just “ok” - but this is a lie, I’m still logged in.

After reading the docs, I added ?returnTo=http%3A%2F%2Flocalhost%3A3000 to the logout url, hoping that at least I will return to the app after the supposed logout, but now something new happens:

Oops!, something went wrong
There could be a misconfiguration in the system or a service outage.

Interesting.

Anyway, what do I do now?


#6

Hey @mbork!

In regards to your feedback to our docs. For future reference it will be helpful if you can report such feedback to our product team via: https://auth0.com/feedback so that we can add it to our roadmap and potentially solve it for wider audience. The same applies to your feedback about our “quickstarts being incomplete”. Sorry for that and we’ll do our best to change it in the future!

Can you provide me with a HAR file so I can investigate why the browser says “ok” while you’re still logged in?

Thanks for help and sorry for inconveniences!


#7

Hey @konrad.sopala

I am still having the same issue and can seem to figure out a solution and was wondering if there are any updates? Thanks!

edit: I had made another post Having trouble with logout on the sample NodeJS app


#8

Closing this one then. I will provide further instructions in the latter one.

Here’s the reference point to it: Having trouble with logout on the sample NodeJS app

For future reference please do not multiply topics.


#9