Files
wekan/models/lib/buttonRulePermission.js
T
Lauri Ojansivu 64123a603a Bind manual rule execution to a writable board and its card
Check write capability and authoritative card board before button dispatch and again in the shared action dispatcher. Board buttons without a card remain supported. Record denied contexts in bounded Problems summaries.

Role and boundary decisions plus dispatcher inventory and existing rule suites pass. Browser regression syntax-check passes; live execution pending.

Thanks to Wenhao Wu, Southeast University and xet7 !
2026-09-14 11:53:05 +03:00

21 lines
886 B
JavaScript

'use strict';
const { memberCan } = require('./boardRoleCapabilities');
function buttonRuleAllowed(userId, board, cardId, card) {
return Boolean(board && memberCan(board.members, userId, 'write') &&
(cardId === undefined || (card && card._id === cardId && card.boardId === board._id)));
}
function requireButtonRuleContext(userId, board, cardId, card, Meteor) {
if (buttonRuleAllowed(userId, board, cardId, card)) return;
try {
require('/server/lib/securityLog').record({
key: 'authz.rule-button', action: 'blocked', source: 'rule:button',
detail: 'Button rule denied because its caller or card is outside the writable board context.',
});
} catch (e) { /* logging must never break the guard */ }
throw new Meteor.Error('not-authorized', 'Button rule context is not authorized.');
}
module.exports = { buttonRuleAllowed, requireButtonRuleContext };