Skip to content

Commit fccf569

Browse files
committed
prevent deleting already graded apps
1 parent a77789a commit fccf569

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

services/registration/src/routes/application.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,14 @@ applicationRouter.route("/:id").delete(
183183
throw new BadRequestError("Application not found or you do not have permission to delete.");
184184
}
185185

186-
console.log("application userId", application.userId);
187-
console.log("req user uid", req.user?.uid);
186+
const allowedStatus = [StatusType.DRAFT, StatusType.APPLIED];
188187
// Ensure only the owner or an authorized admin can delete
189188
if (application.userId !== req.user?.uid && !req.user?.roles.member) {
190189
throw new BadRequestError("You do not have permission to delete this application.");
190+
} else if (!allowedStatus.includes(application.status)) {
191+
throw new BadRequestError(
192+
"You can only delete an application if the status is a draft or applied."
193+
);
191194
}
192195

193196
await ApplicationModel.findByIdAndDelete(req.params.id);

0 commit comments

Comments
 (0)