@7365admin1/core 3.64.5-staging.299 → 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).
package/dist/index.js CHANGED
@@ -29476,6 +29476,31 @@ async function requireMemberOrg(req, org) {
29476
29476
  }
29477
29477
  await requireOrgAccess(req, orgId);
29478
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
+ }
29479
29504
  function memberModulesHandlers({
29480
29505
  requireSelfOrPlatformStaff: requireSelfOrPlatformStaff2,
29481
29506
  gateData
@@ -29579,7 +29604,11 @@ function useMemberController() {
29579
29604
  }
29580
29605
  try {
29581
29606
  const data = await _getAllByUser(userId);
29582
- 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));
29583
29612
  return;
29584
29613
  } catch (error2) {
29585
29614
  import_node_server_utils65.logger.log({