@7365admin1/core 3.52.15 → 3.52.16

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
@@ -13522,6 +13522,22 @@ async function hasOrgOwnership(userId, orgId) {
13522
13522
  );
13523
13523
  return Boolean(found);
13524
13524
  }
13525
+ async function holdsRole(userId, roleId) {
13526
+ const id = userId?.toString() ?? "";
13527
+ const role = roleId?.toString() ?? "";
13528
+ if (!id || !role || !ObjectId25.isValid(id) || !ObjectId25.isValid(role)) {
13529
+ return false;
13530
+ }
13531
+ const db2 = useAtlas16.getDb();
13532
+ if (!db2)
13533
+ return false;
13534
+ const member = await db2.collection("members").findOne({
13535
+ user: new ObjectId25(id),
13536
+ role: new ObjectId25(role),
13537
+ status: { $ne: "deleted" }
13538
+ });
13539
+ return Boolean(member);
13540
+ }
13525
13541
 
13526
13542
  // src/services/service-provider-invite.service.ts
13527
13543
  import {
@@ -18489,6 +18505,11 @@ async function requireRoleOrg(req, org) {
18489
18505
  }
18490
18506
  await requireOrgAccess(req, orgId);
18491
18507
  }
18508
+ async function requireRoleRead(req, roleId, org) {
18509
+ if (await holdsRole(callerId(req), roleId))
18510
+ return;
18511
+ await requireRoleOrg(req, org);
18512
+ }
18492
18513
  function useRoleController() {
18493
18514
  const {
18494
18515
  addRole: _createRole,
@@ -18598,6 +18619,7 @@ function useRoleController() {
18598
18619
  }
18599
18620
  try {
18600
18621
  const data = await _getRoleById(_id);
18622
+ await requireRoleRead(req, _id, data?.org);
18601
18623
  res.json(data);
18602
18624
  return;
18603
18625
  } catch (error2) {
@@ -92087,6 +92109,7 @@ export {
92087
92109
  hasOrgInvitation,
92088
92110
  hasOrgOwnership,
92089
92111
  hidRawUint64,
92112
+ holdsRole,
92090
92113
  incidentReportLog,
92091
92114
  incidents_namespace_collection,
92092
92115
  isCameraEntitled,