mirror of
https://github.com/wekan/wekan.git
synced 2026-11-26 14:45:11 -05:00
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.
35 lines
1.5 KiB
JavaScript
35 lines
1.5 KiB
JavaScript
import Cards from '/models/cards';
|
|
import ChecklistItems from '/models/checklistItems';
|
|
import { denyCrossBoardMoveByChecklistItem } from '/server/lib/utils';
|
|
import { tripCanaryDeny } from '/server/lib/canary';
|
|
import { canEditCardOrLinkedCard } from '/server/lib/linkedCardPermission';
|
|
|
|
ChecklistItems.allow({
|
|
async insert(userId, doc) {
|
|
// ReadOnly users cannot create checklist items
|
|
return await canEditCardOrLinkedCard(userId, await Cards.findOneAsync(doc.cardId));
|
|
},
|
|
async update(userId, doc) {
|
|
// ReadOnly users cannot edit checklist items
|
|
return await canEditCardOrLinkedCard(userId, await Cards.findOneAsync(doc.cardId));
|
|
},
|
|
async remove(userId, doc) {
|
|
// ReadOnly users cannot delete checklist items
|
|
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 item's SOURCE card/board, so a DDP client could move a checklist item
|
|
// into a private board it is not a member of by $set-ting a new cardId or
|
|
// checklistId (boardId is then denormalized from the destination card). Deny any
|
|
// move whose destination board the caller cannot write to.
|
|
ChecklistItems.deny({
|
|
async update(userId, doc, fieldNames, modifier) {
|
|
if (!(await denyCrossBoardMoveByChecklistItem(userId, modifier))) return false;
|
|
return tripCanaryDeny('checklist-item.cross-board-move', { userId });
|
|
},
|
|
fetch: [],
|
|
});
|