Add role-based access control with admin/editor roles

Create adminOnly and adminOrEditor access functions. Add role field
to Users collection (admin/editor, default: editor). Update access control
across all collections and globals to enforce role-based permissions.
This commit is contained in:
2026-01-31 13:03:16 +08:00
parent 2d3d144a66
commit d0e8c3bcff
9 changed files with 148 additions and 22 deletions

View File

@@ -1,5 +1,6 @@
import type { GlobalConfig } from 'payload'
import { adminOnly } from '../access/adminOnly'
import { link } from '@/fields/link'
import { revalidateHeader } from './hooks/revalidateHeader'
@@ -7,6 +8,7 @@ export const Header: GlobalConfig = {
slug: 'header',
access: {
read: () => true,
update: adminOnly,
},
fields: [
{