@7365admin1/core 3.48.1-staging.184 → 3.48.1-staging.185

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,16 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Scope the event-management routes to the caller's own estate.
6
+
7
+ All five `/api/event-management` routes carried `requireAuth` and nothing more,
8
+ and the controller held no authorization identifier of any kind, so any
9
+ signed-in account in any organisation could file an event into another client's
10
+ calendar, read that calendar, and read, rewrite or delete any single event
11
+ reached by id alone.
12
+
13
+ `add` and `getAll` now authorise the site named in the request with
14
+ `requireSiteReach`; the three by-id handlers take the verdict off the STORED row
15
+ with a new module-named `requireEventReach`, which answers "not yours" and "does
16
+ not exist" identically so event ids cannot be enumerated.
package/dist/index.js CHANGED
@@ -59647,6 +59647,14 @@ function useEventManagementController() {
59647
59647
  getEventManagementById: _getEventManagementById,
59648
59648
  deleteEventManagementById: _deleteEventManagementById
59649
59649
  } = useEventManagementRepo();
59650
+ async function requireEventReach(req, id) {
59651
+ const event = await _getEventManagementById(id);
59652
+ const { canReach } = await siteReachOf(req);
59653
+ if (!await canReach(event)) {
59654
+ throw new import_node_server_utils185.NotFoundError("Event not found.");
59655
+ }
59656
+ return event;
59657
+ }
59650
59658
  async function add(req, res, next) {
59651
59659
  try {
59652
59660
  const { error, value } = schemaEventManagement.validate(req.body, {
@@ -59658,6 +59666,7 @@ function useEventManagementController() {
59658
59666
  next(new import_node_server_utils185.BadRequestError(messages));
59659
59667
  return;
59660
59668
  }
59669
+ await requireSiteReach(req, value.site);
59661
59670
  const data = await _add(value);
59662
59671
  res.status(201).json(data);
59663
59672
  return;
@@ -59691,6 +59700,7 @@ function useEventManagementController() {
59691
59700
  return;
59692
59701
  }
59693
59702
  const { search, page, limit, site, status, type, startDate, endDate, sort, order } = value;
59703
+ await requireSiteReach(req, site);
59694
59704
  const sortObj = {
59695
59705
  [sort ?? "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
59696
59706
  };
@@ -59725,7 +59735,7 @@ function useEventManagementController() {
59725
59735
  return;
59726
59736
  }
59727
59737
  const { _id } = value;
59728
- const data = await _getEventManagementById(_id);
59738
+ const data = await requireEventReach(req, _id);
59729
59739
  res.status(200).json(data);
59730
59740
  return;
59731
59741
  } catch (error) {
@@ -59747,6 +59757,7 @@ function useEventManagementController() {
59747
59757
  }
59748
59758
  const { _id, ...rest } = value;
59749
59759
  try {
59760
+ await requireEventReach(req, _id);
59750
59761
  const result = await _updateEventManagementById(_id, rest);
59751
59762
  res.status(200).json({ message: result });
59752
59763
  return;
@@ -59768,6 +59779,7 @@ function useEventManagementController() {
59768
59779
  return;
59769
59780
  }
59770
59781
  const { _id } = value;
59782
+ await requireEventReach(req, _id);
59771
59783
  await _deleteEventManagementById(_id);
59772
59784
  res.status(200).json({ message: "Successfully deleted event." });
59773
59785
  return;