This commit is contained in:
Tom Moor
2023-07-23 17:50:33 -04:00
parent 72adcd10ef
commit f8927ff819

View File

@@ -89,13 +89,14 @@ router.post(
const comment = await Comment.findByPk(id, { const comment = await Comment.findByPk(id, {
transaction, transaction,
rejectOnEmpty: true,
lock: { lock: {
level: transaction.LOCK.UPDATE, level: transaction.LOCK.UPDATE,
of: Comment, of: Comment,
}, },
}); });
const document = await Document.findByPk(comment.documentId, { const document = await Document.findByPk(comment.documentId, {
userId: user.id userId: user.id,
}); });
authorize(user, "comment", document); authorize(user, "comment", document);
authorize(user, "update", comment); authorize(user, "update", comment);
@@ -127,9 +128,10 @@ router.post(
const comment = await Comment.findByPk(id, { const comment = await Comment.findByPk(id, {
transaction, transaction,
rejectOnEmpty: true,
}); });
const document = await Document.findByPk(comment.documentId, { const document = await Document.findByPk(comment.documentId, {
userId: user.id userId: user.id,
}); });
authorize(user, "comment", document); authorize(user, "comment", document);
authorize(user, "delete", comment); authorize(user, "delete", comment);