Files
wekan/server/permissions/checklists.js
T
Lauri Ojansivu 49de60eb04 Edit linked card content from either board.
Delegate source-card edits through a visible active link when the user has write access on the board containing that link. Route content fields, attachments, checklists, subtasks, watchers, labels, custom fields, voting and poker to the source while retaining placement on the linked card.

Thanks to hever and xet7 !

Fixes #1995.
2026-08-18 18:45:14 +03:00

35 lines
1.4 KiB
JavaScript

import Cards from '/models/cards';
import Checklists from '/models/checklists';
import { denyCrossBoardMoveByCard } from '/server/lib/utils';
import { tripCanaryDeny } from '/server/lib/canary';
import { canEditCardOrLinkedCard } from '/server/lib/linkedCardPermission';
Checklists.allow({
async insert(userId, doc) {
// ReadOnly users cannot create checklists
return await canEditCardOrLinkedCard(userId, await Cards.findOneAsync(doc.cardId));
},
async update(userId, doc) {
// ReadOnly users cannot edit checklists
return await canEditCardOrLinkedCard(userId, await Cards.findOneAsync(doc.cardId));
},
async remove(userId, doc) {
// ReadOnly users cannot delete checklists
return await canEditCardOrLinkedCard(userId, await Cards.findOneAsync(doc.cardId));
},
fetch: ['userId', 'cardId'],
});
// Security (GHSA-gv8h-5p3p-6hx7): the allow rule above only checks write access
// on the checklist's SOURCE card/board, so a DDP client could move a checklist
// into a private board it is not a member of by $set-ting a new cardId (the
// Checklists.before.update hook then denormalizes boardId from that destination
// card). Deny any move whose destination board the caller cannot write to.
Checklists.deny({
async update(userId, doc, fieldNames, modifier) {
if (!(await denyCrossBoardMoveByCard(userId, modifier))) return false;
return tripCanaryDeny('checklist.cross-board-move', { userId });
},
fetch: [],
});