Files
wekan/models/lib/boardReadAccess.js
T
Lauri Ojansivu 50bb989eb8 Custom board roles, and team memberships that leave with the team.
#3022 (decided 2026-10-14): a site admin builds named roles in Admin
Panel / People / Roles from the capability matrix - sees all cards,
comments, edits, moves cards, invites - and a board admin gives one to a
member in the same popup as the built-in roles. Board admin stays
built-in. Every permission check asks boardRoleCapabilities, which
answers a custom role from the role; the member's built-in flags carry
the strongest built-in role that grants nothing more (fallbackRoleFor,
checked for every combination), so code reading a flag never grants
more, and a deleted role leaves exactly that. Where a role is asked by
name (hasWorker, isCommentOnly, ...) a custom role reads as the built-in
role that does what it does; commenting is asked as a capability
everywhere. Invites, REST whole-board reads, imports (a foreign custom
role is dropped) and member mapping (all eight flags now, not four)
follow it. The six new strings are translated in all 234 locales.

#4178 (decided 2026-10-14): a team or organization that gives board
memberships takes them away again when the user leaves it - only those:
each records where it came from (grantedBy), a direct membership is
never touched, a board admin is kept, and a board admin's own add or
removal is final. Teams through user edits, LDAP, OIDC and the board
sidebar; organizations where they propagate members.

Also: the Roles Status table gets a Move cards column; the comment form,
reactions and chat ask the comment capability (a No comments member was
offered reactions the server refused).

Tests: customBoardRoles and groupBoardMembership node suites, and the
runtime suites (9 passing) against a real database.

Thanks to xet7 and mfnalex !

Fixes #3022,
Fixes #4178.
2026-10-14 08:20:49 +03:00

21 lines
1.0 KiB
JavaScript

'use strict';
// May this board member read the WHOLE board through the REST API
// (Authentication.checkBoardAccess, server/authentication.js)? Those routes
// return every list, card, checklist and comment, so a member who may see only
// the cards assigned to them is refused (AssignedBleed sibling, 2026-10-02).
//
// The built-in roles keep their long-standing list. A custom role (#3022) is
// judged by what this check is for: whether it sees all cards.
const { memberRoleOf, roleCan, CUSTOM_ROLE_PREFIX } = require('./boardRoleCapabilities');
function memberReadsWholeBoard(member, userId) {
if (!(member && member.userId === userId && member.isActive)) return false;
const role = memberRoleOf(member);
if (role && role.startsWith(CUSTOM_ROLE_PREFIX)) return roleCan(role, 'seesAllCards');
return !member.isNoComments && !member.isCommentOnly && !member.isWorker &&
!member.isNormalAssignedOnly && !member.isCommentAssignedOnly && !member.isReadAssignedOnly;
}
module.exports = { memberReadsWholeBoard };