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?