Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Logout results in: "APIError: No User" #5292

Open
pmeske opened this issue Mar 11, 2024 · 2 comments
Open

Automatic Logout results in: "APIError: No User" #5292

pmeske opened this issue Mar 11, 2024 · 2 comments
Labels
status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@pmeske
Copy link

pmeske commented Mar 11, 2024

Link to reproduction

https://github.com/pmeske/payload/tree/issue/token-expiration

Describe the Bug

When I define a tokenExpiration and wait for the User to get logged out automatically, I always see an Exception in the Server-Logs:

[10:35:59] ERROR (payload): APIError: No User
    at logout (C:\Projekte\playground\inclusiveTest\node_modules\payload\src\auth\operations\logout.ts:29:20)
    at logoutHandler (C:\Projekte\playground\inclusiveTest\node_modules\payload\src\auth\requestHandlers\logout.ts:15:33)
    at Layer.handle [as handle_request] (C:\Projekte\playground\inclusiveTest\node_modules\payload\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Projekte\playground\inclusiveTest\node_modules\payload\node_modules\express\lib\router\route.js:144:13)
    at Route.dispatch (C:\Projekte\playground\inclusiveTest\node_modules\payload\node_modules\express\lib\router\route.js:114:3)
    at Layer.handle [as handle_request] (C:\Projekte\playground\inclusiveTest\node_modules\payload\node_modules\express\lib\router\layer.js:95:5)
    at C:\Projekte\playground\inclusiveTest\node_modules\payload\node_modules\express\lib\router\index.js:284:15
    at Function.process_params (C:\Projekte\playground\inclusiveTest\node_modules\payload\node_modules\express\lib\router\index.js:346:12)
    at next (C:\Projekte\playground\inclusiveTest\node_modules\payload\node_modules\express\lib\router\index.js:280:10)
    at next (C:\Projekte\playground\inclusiveTest\node_modules\payload\node_modules\express\lib\router\route.js:136:14)

I think the Issue is the timing of the Logout. The User gets logged out when the Token / Cookie is already expired. Therefore there is no User to Logout in the payload\src\auth\operations\logout.ts:29.

To Reproduce

Open the Backend and wait for ~2 Minutes to get logged out automatically. Unfortunally I could not reduce that time to something lower than 2 Minutes, because then the application ends in a kind of infinite loop, always refreshing the current Token.

Payload Version

2.11.2

Adapters and Plugins

No response

@pmeske pmeske added the status: needs-triage Possible bug which hasn't been reproduced yet label Mar 11, 2024
@ringge
Copy link

ringge commented May 12, 2024

I also got this error

@PavelGolodoniuc
Copy link

I have a somewhat similar error on v2.25.0.

Clicking Logout in the Admin UI throws the same error, showing the "You have been logged out successfully" page but throwing the exact same error on the server console. In Chrome, I can also see it in the Network Inspector. However, the fact is that I don't get logged out at all. If I click the back button, I am still perfectly logged in.

The weird stuff is that the exact same codebase behaves fine on a different machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

3 participants