# \`oidc.isAuthenticated()\` returns true even though the user does not exist in Auth0

**URL:** <https://community.auth0.com/t/oidc-isauthenticated-returns-true-even-though-the-user-does-not-exist-in-auth0/169242>\
**Category:** Get Help\
**Tags:** authentication-sessions, sessions\
**Created:** [January 19, 2025, 11:51am UTC](https://community.auth0.com/t/oidc-isauthenticated-returns-true-even-though-the-user-does-not-exist-in-auth0/169242 "2025-01-19T11:51:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrienjoly](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adrienjoly/32/50494_2.png) [@adrienjoly](https://community.auth0.com/u/adrienjoly)\
**Post date:** [January 19, 2025, 11:51am UTC](https://community.auth0.com/t/oidc-isauthenticated-returns-true-even-though-the-user-does-not-exist-in-auth0/169242/1 "2025-01-19T11:51:12Z")

</div>

Hi,  
I’ve integrated Auth0 on an nodejs/express application (by following this tutorial: [Auth0 Node (Express) API SDK Quickstarts: Authorization](https://auth0.com/docs/quickstart/backend/nodejs/01-authorization), based on [GitHub - auth0/express-openid-connect: An Express.js middleware to protect OpenID Connect web applications.](https://github.com/auth0/express-openid-connect)) and it’s been working fine.

That being said, applicative logs reveals errors on several requests because `oidc.isAuthenticated()` returns true for users that do not exist in Auth0, according to the `userId` I’m extracting using `request.oidc.user.sub.replace('auth0|', '');` (inspired by [express-openid-connect/EXAMPLES.md at master · auth0/express-openid-connect · GitHub](https://github.com/auth0/express-openid-connect/blob/master/EXAMPLES.md#1-basic-setup)). And there is no trace indicating that these users were freshly created, nor recently deleted.

Is it possible that I’ve forgotten to secure something in the way users login?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [January 21, 2025, 10:13pm UTC](https://community.auth0.com/t/oidc-isauthenticated-returns-true-even-though-the-user-does-not-exist-in-auth0/169242/3 "2025-01-21T22:13:08Z")

</div>

Hi @adrienjoly,

Could you share the error logs and its error description regarding `oidc.isAuthenticated()` returning true for users that do not exist in Auth0?

If you prefer, you can send me a DM me the full log event and your tenant name to investigate further.

Let me also point out that the user\_id should have the format `auth0|123456789` when searching for them on Auth0.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![adrienjoly](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adrienjoly/32/50494_2.png) [@adrienjoly](https://community.auth0.com/u/adrienjoly)\
**Post date:** [January 22, 2025, 9:38am UTC](https://community.auth0.com/t/oidc-isauthenticated-returns-true-even-though-the-user-does-not-exist-in-auth0/169242/4 "2025-01-22T09:38:00Z")

</div>

Thank you for your reply, Rueben! I sent you a private message.

---

<div class="post-metadata">

**Author:** ![adrienjoly](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adrienjoly/32/50494_2.png) [@adrienjoly](https://community.auth0.com/u/adrienjoly)\
**Post date:** [January 26, 2025, 8:26am UTC](https://community.auth0.com/t/oidc-isauthenticated-returns-true-even-though-the-user-does-not-exist-in-auth0/169242/5 "2025-01-26T08:26:49Z")

</div>

Update, I did find an entry for that user in auth0’s user management dashboard, but not in our database. But that user does not exist on our database, and the only log entries I found about them are these error messages. I found no trace of them signing up nor deleting their account.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [January 27, 2025, 11:34pm UTC](https://community.auth0.com/t/oidc-isauthenticated-returns-true-even-though-the-user-does-not-exist-in-auth0/169242/6 "2025-01-27T23:34:16Z")

</div>

Hi @adrienjoly,

I’m glad you were able to find that user in the user management section of the Dashboard.

Let me clarify that logs are only retained for 1 day on the free subscription plan. Therefore, if this user signed up or was deleted more than 24 hours ago, the logs will not show this log event. (Reference: [Log Data Retention](https://auth0.com/docs/deploy-monitor/logs/log-data-retention))

I have checked your tenant further and found that you have only 1 regular database connection. If the user does not exist in your Auth0 database and is maintained separately than the database in Auth0, there can be inconsistencies with the user profile when searching for their profile in your own database. You might want to consider using a custom database if you want to have the users to your own database.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![adrienjoly](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adrienjoly/32/50494_2.png) [@adrienjoly](https://community.auth0.com/u/adrienjoly)\
**Post date:** [February 1, 2025, 4:56pm UTC](https://community.auth0.com/t/oidc-isauthenticated-returns-true-even-though-the-user-does-not-exist-in-auth0/169242/7 "2025-02-01T16:56:54Z")

</div>

Hi Rueben,

I found a way to reproduce the issue:

1. as a visitor on [openwhyd.org](http://openwhyd.org), click on login
2. on the auth0 login form, click on signup
3. enter credentials for new user account  
=\> you are redirected to [openwhyd.org](http://openwhyd.org), the login button is still visible (as if you were not logged in), and no user account was created on openwhyd’s db

Why does this happen?

User account creation must go through the `/register` endpoint, which happens only when user clicked on OUR `/signup` endpoint, because that endpoint specifies `returnTo: `/register’`, but this doesn’t happen when the user clicked on auth0’s “sign up” link. (from auth0 “login” page)

=\> I wrote and merged [a pull request](https://github.com/openwhyd/openwhyd/pull/799) that hopefully fixes this issue.

Thanks again for your help!

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 5, 2025, 9:37pm UTC](https://community.auth0.com/t/oidc-isauthenticated-returns-true-even-though-the-user-does-not-exist-in-auth0/169242/8 "2025-02-05T21:37:11Z")

</div>

Hi @adrienjoly,

Thanks for the follow-up and clarification!

Yes, it sounds good that you have merged a pull request that hopefully fixes the issue.

If you continue having issues this with, please let us know.

Cheers,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 19, 2025, 9:37pm UTC](https://community.auth0.com/t/oidc-isauthenticated-returns-true-even-though-the-user-does-not-exist-in-auth0/169242/9 "2025-02-19T21:37:15Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
