From 82d2e48ee5c3c0f5caf58bbb894080b90406b7a6 Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Wed, 25 Feb 2026 17:04:58 +0100 Subject: [PATCH] feat: enable API key auth on Users collection --- src/collections/Users/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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