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:
@@ -1,16 +1,16 @@
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
import { authenticated } from '../../access/authenticated'
|
||||
import { anyone } from '../../access/anyone'
|
||||
import { adminOrEditor } from '../../access/adminOrEditor'
|
||||
import { slugField } from '@/fields/slug'
|
||||
|
||||
export const Portfolio: CollectionConfig = {
|
||||
slug: 'portfolio',
|
||||
access: {
|
||||
create: authenticated,
|
||||
create: adminOrEditor,
|
||||
read: anyone,
|
||||
update: authenticated,
|
||||
delete: authenticated,
|
||||
update: adminOrEditor,
|
||||
delete: adminOrEditor,
|
||||
},
|
||||
admin: {
|
||||
useAsTitle: 'title',
|
||||
|
||||
Reference in New Issue
Block a user