@7365admin1/core 3.64.5-staging.298 → 3.64.5-staging.300

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ `GET /api/members/users/:id` no longer shows anybody's memberships to any signed-in account. The person and Seven365 staff still get the full list; anyone else gets only the memberships in organisations they belong to, were invited to or own (an empty list, not an error, when there are none).
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Role writes: a site's own module list narrows a role only when the site belongs to the role's organisation. A service provider's role at a client's site is no longer refused modules the client switched off for that site — matching what the role editor now offers.
package/dist/index.js CHANGED
@@ -11769,6 +11769,13 @@ function effectiveSiteModules(orgModules, siteModules) {
11769
11769
  const allowed = site.filter((key) => org.includes(key));
11770
11770
  return allowed.length ? allowed : org;
11771
11771
  }
11772
+ function siteModulesForOrg(site, orgId) {
11773
+ const org = orgId?.toString() ?? "";
11774
+ if (!org)
11775
+ return site?.metadata?.modules;
11776
+ const owner = String(site?.orgId ?? site?.org ?? "");
11777
+ return owner && owner === org ? site?.metadata?.modules : void 0;
11778
+ }
11772
11779
  function rejectedSiteModules(orgModules, requested) {
11773
11780
  if (!narrows(orgModules))
11774
11781
  return [];
@@ -21229,7 +21236,7 @@ async function moduleCeiling(org, site) {
21229
21236
  ]);
21230
21237
  return effectiveSiteModules(
21231
21238
  orgDoc?.modules,
21232
- siteDoc?.metadata?.modules
21239
+ siteModulesForOrg(siteDoc, orgId)
21233
21240
  );
21234
21241
  } catch {
21235
21242
  return [];
@@ -29469,6 +29476,31 @@ async function requireMemberOrg(req, org) {
29469
29476
  }
29470
29477
  await requireOrgAccess(req, orgId);
29471
29478
  }
29479
+ async function membershipsInReach(req, items) {
29480
+ const warn = (error) => {
29481
+ import_node_server_utils65.logger.log({ level: "warn", message: `members/users reach check: ${error?.message}` });
29482
+ return false;
29483
+ };
29484
+ if (!await callerAccountApproved(callerId(req)).catch(warn)) {
29485
+ return { items: [], total: 0 };
29486
+ }
29487
+ const orgs = new Set(
29488
+ items.map((m) => m?.org?.toString?.() ?? "").filter(Boolean)
29489
+ );
29490
+ const own = new Set(
29491
+ await resolveInviteActor(callerId(req)).then((actor) => actor.orgIds.map(String)).catch((error) => (warn(error), []))
29492
+ );
29493
+ const reached = new Set([...orgs].filter((org) => own.has(org)));
29494
+ for (const org of orgs) {
29495
+ if (reached.has(org))
29496
+ continue;
29497
+ const ok = await requireOrgReach(req, org).then(() => true, () => false);
29498
+ if (ok)
29499
+ reached.add(org);
29500
+ }
29501
+ const kept = items.filter((m) => reached.has(m?.org?.toString?.() ?? ""));
29502
+ return { items: kept, total: kept.length };
29503
+ }
29472
29504
  function memberModulesHandlers({
29473
29505
  requireSelfOrPlatformStaff: requireSelfOrPlatformStaff2,
29474
29506
  gateData
@@ -29572,7 +29604,11 @@ function useMemberController() {
29572
29604
  }
29573
29605
  try {
29574
29606
  const data = await _getAllByUser(userId);
29575
- res.json(data);
29607
+ const whole = await requireSelfOrPlatformStaff(req, userId, {
29608
+ resource: "members",
29609
+ action: "view-members"
29610
+ }).then(() => true, () => false);
29611
+ res.json(whole ? data : await membershipsInReach(req, data.items));
29576
29612
  return;
29577
29613
  } catch (error2) {
29578
29614
  import_node_server_utils65.logger.log({