Problem
approveRequest / rejectRequest (server/src/controllers/document.controller.ts:713-716, :787) update requests by bare requestId from the body without verifying it belongs to req.params.id, and never check status === 'pending'. Nonexistent ids surface as Prisma 500s.
Impact
Requests can be approved/rejected through the wrong document route; already-decided requests can be re-decided.
Fix
Scope writes with updateMany({ where: { id: requestId, documentId: params.id, status: 'pending' } }) and treat zero matches as 404/409.
Problem
approveRequest/rejectRequest(server/src/controllers/document.controller.ts:713-716,:787) update requests by barerequestIdfrom the body without verifying it belongs toreq.params.id, and never checkstatus === 'pending'. Nonexistent ids surface as Prisma 500s.Impact
Requests can be approved/rejected through the wrong document route; already-decided requests can be re-decided.
Fix
Scope writes with
updateMany({ where: { id: requestId, documentId: params.id, status: 'pending' } })and treat zero matches as 404/409.