mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
GET /api/user and the attachmentMigrationStatuses publication found the caller's boards with a dotted 'members.userId', which also matches boards the caller was removed from, so a removed member kept seeing those board ids (and the publication looked for public boards by a field that does not exist). Both match active memberships now, and boards readable without membership by the shared rule. POST /api/boards/:boardId/copy hand-wrote its admin check without isActive, so a removed former admin could still copy the board; it uses Authentication.checkBoardAdmin. Negative tests fail on any REST handler or publication that finds the caller's boards by a dotted members.userId, or that hand-writes the admin check. Thanks to xet7 !
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
import AttachmentMigrationStatus from '/models/attachmentMigrationStatus';
|
|
import Boards from '/models/boards';
|
|
import Users from '/models/users';
|
|
|
|
// Publish attachment migration status for boards user has access to
|
|
Meteor.publish('attachmentMigrationStatus', async function(boardId) {
|
|
if (!this.userId) {
|
|
return this.ready();
|
|
}
|
|
|
|
check(boardId, String);
|
|
|
|
const board = await Boards.findOneAsync(boardId);
|
|
if (!board || !board.isVisibleBy({ _id: this.userId })) {
|
|
return this.ready();
|
|
}
|
|
|
|
// Publish migration status for this board
|
|
return AttachmentMigrationStatus.find({ boardId });
|
|
});
|
|
|
|
// Publish all attachment migration statuses for user's boards
|
|
Meteor.publish('attachmentMigrationStatuses', async function() {
|
|
if (!this.userId) {
|
|
return this.ready();
|
|
}
|
|
|
|
const user = await Users.findOneAsync(this.userId);
|
|
if (!user) {
|
|
return this.ready();
|
|
}
|
|
|
|
// Get all boards user has access to
|
|
// StaleBleed sibling (2026-10-02): only boards the user is an ACTIVE member
|
|
// of (a dotted 'members.userId' also matched boards they were removed from),
|
|
// and the boards a signed-in user reads without membership (public and
|
|
// instance - `isPublic` does not exist).
|
|
const { withoutMembershipSelectors } = require('/models/lib/boardPermission');
|
|
const boards = await Boards.find({
|
|
$or: [
|
|
{ members: { $elemMatch: { userId: this.userId, isActive: true } } },
|
|
...withoutMembershipSelectors(true),
|
|
],
|
|
}, { fields: { _id: 1 } }).fetchAsync();
|
|
|
|
const boardIds = boards.map(b => b._id);
|
|
|
|
// Publish migration status for all user's boards
|
|
return AttachmentMigrationStatus.find({ boardId: { $in: boardIds } });
|
|
});
|