Skip to content

Commit

Permalink
Merge pull request #947 from pjmartorell/fix/voting-arbitrary-boxer
Browse files Browse the repository at this point in the history
Fix bug when passing an unrelated boxer id as a voteId to `POST /api/votes/<combatId>` endpoint
  • Loading branch information
midudev authored May 6, 2024
2 parents aa04525 + 7f95eaf commit 358f0de
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pages/api/votes/[combatId].ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const POST: APIRoute = async ({ params, request }) => {
if (!success) return res("Bad request", { status: 400 })

const { voteId } = output
const boxerData = combatData.boxers.find((b) => b === voteId)
if (!boxerData) return res("Boxer not found", { status: 404 })

const userId = session.user.id
const votedAt = NOW
Expand Down

0 comments on commit 358f0de

Please sign in to comment.