mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
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 !
21 lines
886 B
JavaScript
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 };
|