A published global is read-only in the admin to a user whose update access allows drafts
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- nextjs, react, typescript
- Domain
- authorization, frontend
Research direction
Open the global branch of the permission probe in packages/next/src/views/Document/getDocumentPermissions.tsx (on main, packages/ui/src/utilities/getDocumentPermissions.ts) and read it next to the collection branch just above, which already spreads { ...data, _status: 'draft' }. Compare that with the client refetch in providers/DocumentInfo/useGetDocPermissions.tsx, which posts the same draft status to /globals/{slug}/access. Apply the same spread in the global call, then verify with the reproduction repo that an editor sees Save Draft but not Publish changes on a published global, and run the existing access/permissions tests for globals.
Written by the indexing model from the issue text.
Description
Describe the Bug
An access rule that lets a user save drafts but not publish (the aim of the docs' Controlling who can publish, written as a check on the incoming data._status so a draft can be saved over a published document) works in the admin for a collection and not for a global.
On a collection, the edit view asks update access with { ...data, _status: 'draft' }, so such a user gets an editable form and a Save Draft button over a published document. On a global, the view asks update with data as stored. Once the global is published, that is _status: 'published', so the rule refuses: the form is read-only and no button is shown. The publish probe (hasPublishPermission) then asks the same question, so for a published global no access rule can tell "may save a draft" from "may publish".
The rest of Payload already treats globals like collections here:
- the client's refetch,
useGetDocPermissions(@payloadcms/ui,providers/DocumentInfo/useGetDocPermissions.tsx), posts{ ...doc, _status: 'draft' }to/globals/{slug}/access. But since the server's first render shows no Save button, it never runs; - the global's update operation lets the same user save a draft: in the reproduction,
POST /api/globals/settings?draft=trueas the editor succeeds,POST /api/globals/settings/accesswith_status: 'draft'returnsupdate: true, and publishing as the editor returns 403.
Where (packages/next/src/views/Document/getDocumentPermissions.tsx on 3.x; the same code in packages/ui/src/utilities/getDocumentPermissions.ts on main):
// collection branch
docPermissions = await docAccessOperation({
id,
collection: { config: collectionConfig },
data: { ...data, _status: 'draft' },
req,
})
// global branch
docPermissions = await docAccessOperationGlobal({
data, // as stored: `_status: 'published'` once published
globalConfig,
req,
})
Expected: the global branch asks with { ...data, _status: 'draft' }, as the collection branch and the client's refetch do. With that one change applied to the installed @payloadcms/next 3.94.1 (dist/views/Document/getDocumentPermissions.js), the editor in the reproduction gets an editable global with Save Draft and still no Publish changes; the admin's view is unchanged.
Link to the code that reproduces this issue
https://github.com/khaleel737/payload-global-draft-access
Reproduction Steps
The reproduction is the blank template (pnpx create-payload-app@latest -t blank, SQLite) with a role on Users, a settings global with drafts and a posts collection with drafts, both using this update rule (src/access/drafts-or-admin.ts):
import type { Access } from 'payload'
const publishes = (data: unknown): boolean =>
typeof data === 'object' && data !== null && '_status' in data && data._status === 'published'
/** Anyone signed in may save drafts; only an admin may publish. */
export const draftsOrAdmin: Access = ({ data, req: { user } }) =>
Boolean(user) && (user?.role === 'admin' || !publishes(data))
cp .env.example .env, setPAYLOAD_SECRET,pnpm install,pnpm dev.- Create the first user at
/adminwith roleadmin, then a second user with roleeditor. - As the admin, open
/admin/globals/settings, type a title and click Publish changes. Create a post and click Publish changes too. - Sign in as the editor and open
/admin/globals/settings: the title field is read-only and there is no Save Draft button. - As the editor, open the published post: the title is editable and Save Draft is there.
Checked in headless Chromium against the reproduction:
| User | View | Title field | Buttons |
|---|---|---|---|
| editor | published global | read-only | none |
| editor | published post | editable | Save Draft |
| admin | published global | editable | Save Draft, Publish changes |
| admin | published post | editable | Save Draft, Publish changes |
Which area(s) are affected?
area: ui
Environment Info
Binaries:
Node: 26.13.1
npm: 11.19.1
pnpm: 12.16.1
Relevant Packages:
payload: 3.94.1
next: 16.4.6
@payloadcms/db-sqlite: 3.94.1
@payloadcms/drizzle: 3.94.1
@payloadcms/graphql: 3.94.1
@payloadcms/next/utilities: 3.94.1
@payloadcms/richtext-lexical: 3.94.1
@payloadcms/translations: 3.94.1
@payloadcms/ui/shared: 3.94.1
react: 19.2.9
react-dom: 19.2.9
Operating System:
Platform: darwin
Arch: x64
The global branch reads the same on 3.x and main today.
- Dominant language
- TypeScript
- Stars
- 45.8k
- Forks
- 4.4k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from payloadcms/payload
-
Accessibility: list row and select-all checkboxes still unnamed in 3.x (#17376 fix not in 3.91)OpenBug Payload OSS
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
payloadcms/payload#19837 ·
Maintainers usually reply within 1 day
-
Bug Payload OSS
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
payloadcms/payload#19835 ·
Maintainers usually reply within 1 day
-
Bug Payload OSS
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
payloadcms/payload#19833 ·
Maintainers usually reply within 1 day
-
Bug Payload OSS
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
payloadcms/payload#19832 ·
Maintainers usually reply within 1 day
-
db-d1-sqlite: upsert is aliased to updateOne, so payload.kv.set never inserts new keysPossibly taken @pcbeingused333 claimed this 3 days ago. OpenBug db: d1-sqlite Payload OSS
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
payloadcms/payload#19766 ·
Maintainers usually reply within 1 day
All issues in payloadcms/payload
Similar issues
-
Add: GTrekkerOpencheck:passed streams:add
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
external
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ClickHouse/ClickStack#3761 ·
Maintainers usually reply within 1 day
-
fix(auth): add the email OTP verification step to Pollar loginPossibly taken @akansnoro claimed this today. OpenStellar Wave
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
safetrustcr/dApp-SafeTrust#584 · 10 comments ·
Maintainers usually reply within 1 day
-
The manager preset saves launch definitions without the required file and digest pairPossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day