Lock down injected users, 2FA slug, forms and globals writes
- Injected auth collection with roles: admins manage all accounts, others only themselves (Payload's default let any account edit or delete any other) - 2FA defaults to the resolved auth collection instead of 'users' - SiteSettings, CookieSettings, Notifications, Forms: write needs editor+; form Emails tab readable by editor+ only Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
12fbd424a5
commit
10da62ea4c
@@ -1,5 +1,6 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { adminOrEditor } from '../../modules/access/index.js'
|
||||
import { cookieSettingsFields } from './fields.js'
|
||||
|
||||
/**
|
||||
@@ -11,6 +12,7 @@ export function buildCookieSettings(): GlobalConfig {
|
||||
slug: 'cookie-settings',
|
||||
access: {
|
||||
read: () => true,
|
||||
update: adminOrEditor, // consent texts are legal copy — not for plain 'user' accounts
|
||||
},
|
||||
admin: {
|
||||
group: 'Settings',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { adminOrEditor } from '../../modules/access/index.js'
|
||||
import { notificationsFields } from './fields.js'
|
||||
|
||||
/**
|
||||
@@ -12,6 +13,7 @@ export function buildNotifications(): GlobalConfig {
|
||||
slug: 'notifications',
|
||||
access: {
|
||||
read: () => true, // texts are public-facing (shown to end users)
|
||||
update: adminOrEditor,
|
||||
},
|
||||
admin: { group: 'Settings' },
|
||||
fields: notificationsFields,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Field, GlobalConfig } from 'payload'
|
||||
|
||||
import { adminOrEditor } from '../../modules/access/index.js'
|
||||
import { generalFields } from './fields/general.js'
|
||||
import { themeFields } from './fields/theme.js'
|
||||
|
||||
@@ -42,6 +43,9 @@ export function buildSiteSettings({
|
||||
slug: 'site-settings',
|
||||
access: {
|
||||
read: () => true,
|
||||
// Editors and admins only — a plain 'user' account (open sign-up) must
|
||||
// not rewrite the brand, homepage or construction mode.
|
||||
update: adminOrEditor,
|
||||
},
|
||||
admin: {
|
||||
group: 'Settings',
|
||||
|
||||
Reference in New Issue
Block a user