Files
wekan/models/lib/boardPermission.js
T
Lauri Ojansivu f122a8287c Add semi-open boards, visible to every signed-in user.
A board's visibility can now be "Signed-in users" (permission 'instance'):
every signed-in user of this WeKan reads it, nobody signed out does, and
only its members edit it, as on a public board. One pure rule,
models/lib/boardPermission.js, feeds isVisibleBy and the shared selector
builder, so the board and card publications, All Boards, search, exports,
attachments, backgrounds, watching, filter presets and rule destinations
follow it. Anonymous paths - link previews, public avatars, the no-token
export branch and archived lists - stay public-only, and a source suite
lists every remaining public-only check so a new one is reviewed. The
Public page and GET /api/boards list instance boards for a signed-in caller
only; "private boards only" refuses them like public ones; a WeKan export
keeps the setting on import. New strings are English, pending Transifex.

Fixes #3249,

Thanks to relikd and xet7 !
2026-09-29 16:28:44 +03:00

39 lines
1.7 KiB
JavaScript

'use strict';
// wekan/wekan#3249 (maintainer decision 2026-09-29): semi-open boards. A board's
// `permission` is one of three:
//
// 'private' - only its active members (and org/team/domain shares) read it;
// 'instance' - every signed-in user of this WeKan reads it, and it is never
// in an unauthenticated response: not on the anonymous Public
// page, not in link previews, not over REST without a token;
// 'public' - anybody reads it, signed in or not.
//
// Reading is all 'instance' grants: editing still needs membership, exactly as
// on a public board. This module is the one statement of that rule; it is pure
// so tests/boardPermission.test.cjs checks it directly.
const BOARD_PERMISSIONS = ['private', 'instance', 'public'];
// May somebody read this board without being one of its members?
// `signedIn` is whether the caller is an authenticated user.
function readableWithoutMembership(permission, signedIn) {
if (permission === 'public') return true;
if (permission === 'instance') return !!signedIn;
return false;
}
// The Mongo clauses for boards readable without membership - the counterpart
// of readableWithoutMembership() for queries.
function withoutMembershipSelectors(signedIn) {
return signedIn ? [{ permission: 'public' }, { permission: 'instance' }] : [{ permission: 'public' }];
}
// Anything but private. Admin Panel → Settings → Visibility "private boards
// only" refuses both open kinds.
function isOpenPermission(permission) {
return permission === 'public' || permission === 'instance';
}
module.exports = { BOARD_PERMISSIONS, readableWithoutMembership, withoutMembershipSelectors, isOpenPermission };