fix(issues): only allow edit of own comments & do not allow non-admin delete of issues with comments (#2248)

This commit is contained in:
TheCatLady
2021-10-30 19:54:01 -04:00
committed by GitHub
parent 0828b008ba
commit bba09d69c1
5 changed files with 63 additions and 59 deletions

View File

@@ -302,7 +302,7 @@ issueRoutes.delete('/:issueId', async (req, res, next) => {
if (
!req.user?.hasPermission(Permission.MANAGE_ISSUES) &&
issue.createdBy.id !== req.user?.id
(issue.createdBy.id !== req.user?.id || issue.comments.length > 1)
) {
return next({
status: 401,

View File

@@ -68,13 +68,10 @@ issueCommentRoutes.put<
where: { id: Number(req.params.commentId) },
});
if (
!req.user?.hasPermission([Permission.MANAGE_ISSUES], { type: 'or' }) &&
comment.user.id !== req.user?.id
) {
if (comment.user.id !== req.user?.id) {
return next({
status: 403,
message: 'You do not have permission to edit this comment.',
message: 'You can only edit your own comments.',
});
}