diff --git a/src/collections/Users/index.ts b/src/collections/Users/index.ts index 420c33f..030f72b 100644 --- a/src/collections/Users/index.ts +++ b/src/collections/Users/index.ts @@ -1,7 +1,6 @@ import type { CollectionConfig } from 'payload' import { authenticated } from '../../access/authenticated' -// Only admins can manage users const adminOnly = ({ req: { user } }: any) => user?.role === 'admin' export const Users: CollectionConfig = { @@ -11,13 +10,15 @@ export const Users: CollectionConfig = { create: adminOnly, delete: adminOnly, read: authenticated, - update: authenticated, // users can update themselves; field-level locks the role field + update: authenticated, }, admin: { defaultColumns: ['name', 'email', 'role'], useAsTitle: 'name', }, - auth: true, + auth: { + useAPIKey: true, + }, fields: [ { name: 'name', @@ -34,7 +35,6 @@ export const Users: CollectionConfig = { { label: 'Admin', value: 'admin' }, { label: 'Redaktör', value: 'editor' }, ], - // Only admins can change roles access: { update: adminOnly, }, @@ -44,4 +44,4 @@ export const Users: CollectionConfig = { }, ], timestamps: true, -} +} \ No newline at end of file