Fix: Requesting approvals on previously rejected resources

This commit is contained in:
Daniel Hougaard
2024-04-05 18:57:14 -07:00
parent 1785548a40
commit c7d2dfd351

View File

@@ -128,7 +128,15 @@ export const accessApprovalRequestServiceFactory = ({
throw new BadRequestError({ message: "You already have an active privilege with the same criteria" });
}
} else {
throw new BadRequestError({ message: "You already have a pending access request with the same criteria" });
const reviewers = await accessApprovalRequestReviewerDAL.find({
requestId: duplicateRequest.id
});
const isRejected = reviewers.some((reviewer) => reviewer.status === ApprovalStatus.REJECTED);
if (!isRejected) {
throw new BadRequestError({ message: "You already have a pending access request with the same criteria" });
}
}
}