@7365admin1/core 3.65.1 → 3.65.2

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.
package/dist/index.mjs CHANGED
@@ -28201,6 +28201,31 @@ async function requireMemberOrg(req, org) {
28201
28201
  }
28202
28202
  await requireOrgAccess(req, orgId);
28203
28203
  }
28204
+ async function membershipsInReach(req, items) {
28205
+ const warn = (error) => {
28206
+ logger37.log({ level: "warn", message: `members/users reach check: ${error?.message}` });
28207
+ return false;
28208
+ };
28209
+ if (!await callerAccountApproved(callerId(req)).catch(warn)) {
28210
+ return { items: [], total: 0 };
28211
+ }
28212
+ const orgs = new Set(
28213
+ items.map((m) => m?.org?.toString?.() ?? "").filter(Boolean)
28214
+ );
28215
+ const own = new Set(
28216
+ await resolveInviteActor(callerId(req)).then((actor) => actor.orgIds.map(String)).catch((error) => (warn(error), []))
28217
+ );
28218
+ const reached = new Set([...orgs].filter((org) => own.has(org)));
28219
+ for (const org of orgs) {
28220
+ if (reached.has(org))
28221
+ continue;
28222
+ const ok = await requireOrgReach(req, org).then(() => true, () => false);
28223
+ if (ok)
28224
+ reached.add(org);
28225
+ }
28226
+ const kept = items.filter((m) => reached.has(m?.org?.toString?.() ?? ""));
28227
+ return { items: kept, total: kept.length };
28228
+ }
28204
28229
  function memberModulesHandlers({
28205
28230
  requireSelfOrPlatformStaff: requireSelfOrPlatformStaff2,
28206
28231
  gateData
@@ -28304,7 +28329,11 @@ function useMemberController() {
28304
28329
  }
28305
28330
  try {
28306
28331
  const data = await _getAllByUser(userId);
28307
- res.json(data);
28332
+ const whole = await requireSelfOrPlatformStaff(req, userId, {
28333
+ resource: "members",
28334
+ action: "view-members"
28335
+ }).then(() => true, () => false);
28336
+ res.json(whole ? data : await membershipsInReach(req, data.items));
28308
28337
  return;
28309
28338
  } catch (error2) {
28310
28339
  logger37.log({