33 lines
981 B
TypeScript
33 lines
981 B
TypeScript
import type { CollectionConfig } from 'payload';
|
|||
|
|
|
||
|
|
/**
|
||
|
|
* The site's only authenticated surface. There is one account and no
|
||
|
|
* registration: `create` is closed to everyone, so the first user is seeded
|
||
|
|
* with `payload create-first-user` and no one can add another through the API.
|
||
|
|
*/
|
||
|
|
export const Users: CollectionConfig = {
|
||
|
|
slug: 'users',
|
||
|
|
auth: {
|
||
|
|
// Slows credential stuffing against a panel that is on the public
|
||
|
|
// internet. Five attempts, then a ten-minute lock.
|
||
|
|
maxLoginAttempts: 5,
|
||
|
|
lockTime: 10 * 60 * 1000,
|
||
|
|
},
|
||
|
|
access: {
|
||
|
|
create: () => false,
|
||
|
|
read: ({ req }) => Boolean(req.user),
|
||
|
|
update: ({ req }) => Boolean(req.user),
|
||
|
|
delete: () => false,
|
||
|
|
},
|
||
|
|
admin: { useAsTitle: 'email' },
|
||
|
|
fields: [
|
||
|
|
{
|
||
|
|
name: 'displayName',
|
||
|
|
type: 'text',
|
||
|
|
required: true,
|
||
|
|
// Rendered as the byline on every post. First name only — the site
|
||
|
|
// publishes no surname and no employer.
|
||
|
|
defaultValue: 'Tudor',
|
||
|
|
},
|
||
|
|
],
|
||
|
|
};
|