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',
|
||||
},
|
||||
LIST_NOT_FOUND: {
|
||||
listNotFound: 'List not found',
|
||||
},
|
||||
|
@ -14,6 +17,9 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
notEnoughRights: {
|
||||
responseType: 'forbidden',
|
||||
},
|
||||
listNotFound: {
|
||||
responseType: 'notFound',
|
||||
},
|
||||
|
@ -26,12 +32,19 @@ module.exports = {
|
|||
.getProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.LIST_NOT_FOUND);
|
||||
|
||||
const isBoardMember = await sails.helpers.users.isBoardMember(currentUser.id, list.boardId);
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: list.boardId,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
if (!isBoardMember) {
|
||||
if (!boardMembership) {
|
||||
throw Errors.LIST_NOT_FOUND; // Forbidden
|
||||
}
|
||||
|
||||
if (boardMembership.role !== BoardMembership.Roles.EDITOR) {
|
||||
throw Errors.NOT_ENOUGH_RIGHTS;
|
||||
}
|
||||
|
||||
list = await sails.helpers.lists.deleteOne(list, this.req);
|
||||
|
||||
if (!list) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue