Skip to content

fix: avoid duplicating current user in query preset access list#17042

Open
yashs33244 wants to merge 1 commit into
payloadcms:mainfrom
yashs33244:fix/presets-duplicate-users-crash
Open

fix: avoid duplicating current user in query preset access list#17042
yashs33244 wants to merge 1 commit into
payloadcms:mainfrom
yashs33244:fix/presets-duplicate-users-crash

Conversation

@yashs33244

Copy link
Copy Markdown

What?

When a query preset uses the "Specific Users" access constraint, the current user was appended to the users list on every save. Re-saving an existing preset (e.g. editing the title, or adding/removing a user) duplicated the logged-in user each time.

Why?

The users field beforeChange hook unconditionally did [...users, req.user.id] for the specificUsers constraint, so the request user was re-added on each create/update even when already present.

How?

Only append req.user.id when it isn't already in the list, which keeps the lockout-prevention guarantee (the current user stays in the list) without creating duplicates. Added an integration test that re-saves a preset and asserts the user appears exactly once.

Fixes #15672

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Presets - duplicated users & crashes when opening preset list

1 participant