Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #718 from Northeastern-Electric-Racing/#650-review…
Browse files Browse the repository at this point in the history
…-own-cr-be

#650 - add back-end check to prevent reviewing your own cr
  • Loading branch information
jamescd18 authored Jun 15, 2022
2 parents 3082c92 + 1ae5f03 commit 447ebf8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/backend/functions/change-requests-review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ export const reviewChangeRequest: Handler<FromSchema<typeof inputSchema>> = asyn
if (reviewer.role === Role.GUEST || reviewer.role === Role.MEMBER) return buildNoAuthResponse();

// ensure existence of change request
const foundCR = prisma.change_Request.findUnique({ where: { crId } });
const foundCR = await prisma.change_Request.findUnique({ where: { crId } });
if (!foundCR) return buildNotFoundResponse('change request', `#${crId}`);

// verify that the user is not reviewing their own change request
if (reviewerId === foundCR.submitterId) return buildNoAuthResponse();

// update change request
const update = await prisma.change_Request.update({
where: { crId },
Expand Down

0 comments on commit 447ebf8

Please sign in to comment.