mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 10:48:06 -05:00
#5695 #4897 #4654 #5174 #4825 #5659 #4730 #4419 #4158 #4560 #4036
#1959 #1971.
- Startup schema upgrade (server/lib/schemaUpgradeSteps.js): on start,
check that data from EVERY old WeKan version is migrated to the newest
structure and migrate only what is missing - all platforms, MongoDB and
FerretDB. Version-gated (marker stores WeKan version + datetime of the
last re-check; one findOne per boot until a new release), non-blocking,
live dashboard at /schema-upgrade-status showing the product name, fast
on big databases (distinct() set-joins, updateMany batches). Steps:
archived-flag backfill, swimlane structure + visibility rescue
(#1959 #1971: cards under deleted/archived/foreign swimlanes reassigned
to a visible swimlane; card-insert hook validates supplied swimlaneIds),
merge-per-swimlane-lists (v7.98/v8.0x list copies merged back into
shared lists: no duplicate columns in Lists view, everything visible in
Swimlanes view, cards keep their swimlane), embedded checklist items,
customFields boardIds, allows* backfills, members isActive, permission
lowercase, filesystem path healing.
- Migration speed (5-hour reports): insertMany batches in the text phase,
preloaded target-record maps in the file phases.
- Snap attachment-repair + FILES_ONLY importer mode (see prior commit
wiring) extended with CFS FileSystem-store coverage
(ATTACHMENTS_STORE_PATH era), missing-binary reporting, and
migrate-gridfs-to-fs.mjs bucket fixes.
- OAuth2/OIDC: OAUTH2_LOGIN_STYLE=redirect honored (#5695); concurrent
logins no longer contaminate each other's user data (#4897); account
merge no longer wipes avatars/templates (#4560).
- LDAP: background sync fixed (#4654), password login rejected after LDAP
migration (#4419), LDAP_ENCRYPTION=true actually encrypts (#4158),
group filter accepts multiple groups and admits admin-sync groups
(#4036).
- All Boards tiles: per-list card counts + member avatars restored
non-reactively (#5174 #4825). Uniform default list widths (#5659).
Declined invitations no longer resurrect membership (#4730).
- Tests with negative cases for every fix (tests/*.test.cjs; suite green
except the pre-existing environment-only htmljs failure).
Closes #5600: OAUTH2_CA_CERT already works - the fetch migration
(49a272d6c) applies the CA to all OIDC calls via https.Agent.
Closes #3828: board members seeing all board cards is by design (no
per-card visibility model), and organizations/teams now exist.
Thanks to mueschel, ArturRuta, gerardo-junior, fabianrbz, Miuler,
butteredCat-2021, Griiimm, preciousamorc, farwayer, LeoLu-eng, hnb1,
rangersdo and xet7.
109 lines
4.4 KiB
JavaScript
109 lines
4.4 KiB
JavaScript
'use strict';
|
|
|
|
// Pure decision logic for keeping board memberships in sync when a user's
|
|
// teams change. Extracted so it is unit-testable without Meteor
|
|
// (see tests/teamBoardMemberSync.test.cjs).
|
|
//
|
|
// #4593 ("The new added user that was assigned to existing team cannot be
|
|
// applied to kanban with the right authority"): when a team is assigned to a
|
|
// board through the board sidebar (addBoardTeamPopup), every user who is in
|
|
// the team AT THAT MOMENT is pushed into board.members as a normal member.
|
|
// But a user added to the team AFTERWARDS never got a member entry: the
|
|
// publications grant them read visibility of the board (boards / board
|
|
// publications match `teams.teamId`), yet every authority check that gates
|
|
// interaction — board.hasMember() (models/boards.js), allowIsBoardMember*()
|
|
// (server/lib/utils.js), Attachments.protected (models/attachments.server.js)
|
|
// and board.isVisibleBy() (export) — only looks at board.members. So the new
|
|
// team member could at best view the board read-only, could not download its
|
|
// attachments, and had strictly less authority than teammates who happened to
|
|
// be in the team when it was assigned.
|
|
//
|
|
// These helpers compute, from a user's old and new team lists, which boards
|
|
// must gain the user as a member so a late-joining team member ends up with
|
|
// the same authority the team's original members received.
|
|
|
|
// Return the de-duplicated teamId strings of a user.teams-shaped array
|
|
// (`[{ teamId, teamDisplayName }, ...]`). Tolerates a missing/invalid list and
|
|
// entries without a teamId.
|
|
function teamIdsOf(teams) {
|
|
if (!Array.isArray(teams)) return [];
|
|
const ids = [];
|
|
const seen = new Set();
|
|
teams.forEach(team => {
|
|
const id = team && team.teamId;
|
|
if (!id || typeof id !== 'string' || seen.has(id)) return;
|
|
seen.add(id);
|
|
ids.push(id);
|
|
});
|
|
return ids;
|
|
}
|
|
|
|
// Team ids present in newTeams but not in oldTeams — the teams the user just
|
|
// gained. Removals are intentionally NOT reported: a user removed from a team
|
|
// may also have been invited to a board individually, and membership data
|
|
// cannot tell those apart, so team-loss cleanup stays the explicit board-admin
|
|
// action it always was (removeBoardTeamPopup).
|
|
function gainedTeamIds(oldTeams, newTeams) {
|
|
const before = new Set(teamIdsOf(oldTeams));
|
|
return teamIdsOf(newTeams).filter(id => !before.has(id));
|
|
}
|
|
|
|
// The member entry a team-derived user receives: a plain active, non-admin
|
|
// member, exactly like the entries addBoardTeamPopup creates and with the
|
|
// same fully-defaulted flags reconcileBoardTeamMembers assigns to members
|
|
// introduced through the team-management path.
|
|
function newTeamBoardMemberEntry(userId) {
|
|
return {
|
|
userId,
|
|
isAdmin: false,
|
|
isActive: true,
|
|
isNoComments: false,
|
|
isCommentOnly: false,
|
|
isWorker: false,
|
|
isNormalAssignedOnly: false,
|
|
isCommentAssignedOnly: false,
|
|
isReadOnly: false,
|
|
isReadAssignedOnly: false,
|
|
};
|
|
}
|
|
|
|
// Given the candidate board documents (each with at least _id, type, teams,
|
|
// members), the user id and the team ids the user just gained, return the ids
|
|
// of the boards the user must be added to as a member:
|
|
// - the board must have one of the gained teams assigned AND active,
|
|
// - template boards/containers are skipped (#5850: sharing on those is
|
|
// group-only; the members tab shows only the creator),
|
|
// - a user with ANY existing member entry (even inactive) is left untouched,
|
|
// so an explicit per-board decision (e.g. a deactivated member) is never
|
|
// silently overridden by a team change.
|
|
function boardsToAddMemberTo(boards, userId, gainedIds) {
|
|
if (!userId || typeof userId !== 'string') return [];
|
|
if (!Array.isArray(boards) || !Array.isArray(gainedIds) || !gainedIds.length) {
|
|
return [];
|
|
}
|
|
const gained = new Set(gainedIds);
|
|
const ids = [];
|
|
boards.forEach(board => {
|
|
if (!board || !board._id) return;
|
|
if (board.type === 'template-board' || board.type === 'template-container') {
|
|
return;
|
|
}
|
|
const teams = Array.isArray(board.teams) ? board.teams : [];
|
|
const sharedWithGainedTeam = teams.some(
|
|
team => team && team.isActive === true && gained.has(team.teamId),
|
|
);
|
|
if (!sharedWithGainedTeam) return;
|
|
const members = Array.isArray(board.members) ? board.members : [];
|
|
if (members.some(member => member && member.userId === userId)) return;
|
|
ids.push(board._id);
|
|
});
|
|
return ids;
|
|
}
|
|
|
|
module.exports = {
|
|
teamIdsOf,
|
|
gainedTeamIds,
|
|
newTeamBoardMemberEntry,
|
|
boardsToAddMemberTo,
|
|
};
|