mirror of
https://github.com/plankanban/planka.git
synced 2025-07-20 13:49:43 +02:00
parent
d80a538857
commit
51fa7df69c
61 changed files with 1063 additions and 191 deletions
|
@ -1,4 +1,7 @@
|
|||
const Errors = {
|
||||
NOT_ENOUGH_RIGHTS: {
|
||||
notEnoughRights: 'Not enough rights',
|
||||
},
|
||||
COMMENT_ACTION_NOT_FOUND: {
|
||||
commentActionNotFound: 'Comment action not found',
|
||||
},
|
||||
|
@ -18,6 +21,9 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
notEnoughRights: {
|
||||
responseType: 'forbidden',
|
||||
},
|
||||
commentActionNotFound: {
|
||||
responseType: 'notFound',
|
||||
},
|
||||
|
@ -43,11 +49,18 @@ module.exports = {
|
|||
throw Errors.COMMENT_ACTION_NOT_FOUND; // Forbidden
|
||||
}
|
||||
|
||||
const isBoardMember = await sails.helpers.users.isBoardMember(currentUser.id, board.id);
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
if (!isBoardMember) {
|
||||
if (!boardMembership) {
|
||||
throw Errors.COMMENT_ACTION_NOT_FOUND; // Forbidden
|
||||
}
|
||||
|
||||
if (boardMembership.role !== BoardMembership.Roles.EDITOR && !boardMembership.canComment) {
|
||||
throw Errors.NOT_ENOUGH_RIGHTS;
|
||||
}
|
||||
}
|
||||
|
||||
const values = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue