Skip to content

Commit

Permalink
Extract to prewritten function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ortovoxx committed Mar 8, 2024
1 parent d4749cb commit 64aac3d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/payload/collections/Nominations/access/beforeVoting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import type { FieldAccess } from 'payload/types'

import type { Nomination } from '../../../payload-types'
import { checkRole } from '../../Users/checkRole'
import {getID} from "../../../utilities/getID";

Check failure on line 5 in src/payload/collections/Nominations/access/beforeVoting.ts

View workflow job for this annotation

GitHub Actions / build

Replace `getID}·from·"../../../utilities/getID";` with `·getID·}·from·'../../../utilities/getID'`

export const beforeVoting: FieldAccess<Nomination> = async ({ req, doc }) => {
if (req.user && checkRole(['admin'], req.user)) {
return true
}

// 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',
Expand Down

0 comments on commit 64aac3d

Please sign in to comment.