Files
heygermany-e2e-mrg4m7dd/packages/functions/src/permissions.ts
e2e 6c231d1d36
Some checks failed
Main / Setup and Test (push) Has been cancelled
Main / Build Website (push) Has been cancelled
chore: heygermany customer project
2026-07-11 10:52:27 +02:00

19 lines
621 B
TypeScript

import { pikkuPermission } from "#pikku/pikku-types.gen.js";
export const isBackOffice = pikkuPermission(async (_services, _data, { session }) => {
return session?.type === 'backoffice'
})
export const isCompany = pikkuPermission(async (_services, _data, { session }) => {
return session?.type === 'company'
})
export const isCandidate = pikkuPermission<{ candidateId?: string } | void>(async (_services, data, { session }) => {
if (session?.type !== 'candidate') {
return false
}
if (data?.candidateId && data.candidateId !== session.userId) {
return false
}
return true
})