From 64aac3dbf3c0932cca3778561a8af4f0b3836db2 Mon Sep 17 00:00:00 2001 From: Euan Caskie <56805259+Ortovoxx@users.noreply.github.com> Date: Fri, 8 Mar 2024 21:18:24 +0000 Subject: [PATCH] Extract to prewritten function --- src/payload/collections/Nominations/access/beforeVoting.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/payload/collections/Nominations/access/beforeVoting.ts b/src/payload/collections/Nominations/access/beforeVoting.ts index 0c9dc81..a2769a8 100644 --- a/src/payload/collections/Nominations/access/beforeVoting.ts +++ b/src/payload/collections/Nominations/access/beforeVoting.ts @@ -2,6 +2,7 @@ import type { FieldAccess } from 'payload/types' import type { Nomination } from '../../../payload-types' import { checkRole } from '../../Users/checkRole' +import {getID} from "../../../utilities/getID"; export const beforeVoting: FieldAccess = async ({ req, doc }) => { if (req.user && checkRole(['admin'], req.user)) { @@ -9,7 +10,7 @@ export const beforeVoting: FieldAccess = async ({ req, doc }) => { } // Don't think doc.election will ever not be a string, but just in case - const election = typeof doc.election === 'string' ? doc.election : doc.election.id + const election = getID(doc.election) const result = await req.payload.findByID({ collection: 'elections',