import type { AuthStrategy } from 'payload' // Signs in the Payload user whose email is the visitor's exe.dev account. // exe.dev's HTTPS proxy sets X-ExeDev-Email for visitors signed in to // exe.dev and removes any copy of the header a visitor sends, so it can't // be faked. Passwords keep working for everyone else. // From https://exe.dev/deploy/payload export const exedevAuth: AuthStrategy = { name: 'exe.dev', authenticate: async ({ headers, payload }) => { const email = headers.get('x-exedev-email')?.trim().toLowerCase() if (!email) return { user: null } const { docs } = await payload.find({ collection: 'users', depth: 0, limit: 1, overrideAccess: true, where: { email: { equals: email } }, }) return { user: docs[0] ? { ...docs[0], _strategy: 'exe.dev', collection: 'users' } : null } }, }