mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 15:13:07 +00:00
The four public globals (site-settings, home, metadata, privacy-policy) spelled update access as "any authenticated user" — and campaign JWTs authenticate against /api/*, so any campaign session (leader included) could PATCH the public site. payloadAdminOnly matches the collection lockdown precedent; editors lose config-global writes deliberately (content editing stays on canManagePublishedContent collections). Pins: identity + deny (coordinator/editor) + allow (admin fn) + anonymous read in collectionAccessLockdown.int.spec.ts. Recurrence guard: globalAccessConventions.unit.spec.ts bans the Boolean(user) shape in src/globals. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { payloadAdminOnly } from '@/utilities/campaignAccess'
|
|
import { revalidateGlobal } from '@/utilities/globals'
|
|
import type { GlobalConfig } from 'payload'
|
|
|
|
const slug = 'privacy-policy'
|
|
|
|
const revalidate = async ({ context }: { context?: { skipRevalidation?: boolean } }) => {
|
|
if (context?.skipRevalidation) return
|
|
await revalidateGlobal(slug)
|
|
}
|
|
|
|
export const PrivacyPolicy: GlobalConfig = {
|
|
slug,
|
|
label: 'Política de Privacidade',
|
|
admin: {
|
|
group: 'Configurações',
|
|
description:
|
|
'Aviso de Privacidade institucional exibido em /privacidade. Publicar somente após revisão jurídica.',
|
|
},
|
|
access: {
|
|
read: () => true,
|
|
// Legal text: admin-only like the other site globals (Pass 4) — campaign
|
|
// JWTs reach /api/*.
|
|
update: payloadAdminOnly,
|
|
},
|
|
hooks: {
|
|
afterChange: [revalidate],
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'published',
|
|
type: 'checkbox',
|
|
label: 'Publicado',
|
|
defaultValue: false,
|
|
admin: {
|
|
description: 'Quando desmarcado, a rota pública /privacidade retorna 404.',
|
|
},
|
|
},
|
|
{
|
|
name: 'body',
|
|
type: 'richText',
|
|
label: 'Texto',
|
|
required: true,
|
|
},
|
|
],
|
|
}
|