@7365admin1/core 3.48.1-staging.183 → 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
@@ -29881,7 +29881,7 @@ function useSubscriptionService() {
29881
29881
  }
29882
29882
  const items = [];
29883
29883
  const dueInvoice = await getByDueDate(
29884
- subscription.nextBillingDate,
29884
+ new Date(subscription.nextBillingDate),
29885
29885
  "pending"
29886
29886
  );
29887
29887
  if (value.promoCode) {
@@ -30022,7 +30022,13 @@ function useSubscriptionService() {
30022
30022
  {
30023
30023
  _id: value.subscriptionId,
30024
30024
  currentSeats: value.seats,
30025
- maxSeats: 0,
30025
+ // Keep the organisation's own seat limit. It is worked out above —
30026
+ // the current limit, raised when the new seat count is larger — and
30027
+ // was then thrown away here in favour of a literal 0. Now that 0
30028
+ // means UNLIMITED, writing it handed the organisation an uncapped
30029
+ // subscription on every seat change. A plan that really is unlimited
30030
+ // is already 0 above, so it still passes through untouched.
30031
+ maxSeats,
30026
30032
  paidSeats: paidSeats > value.seats ? paidSeats : value.seats,
30027
30033
  promoCode: value.promoCode ?? "",
30028
30034
  amount: value.seats * Number(newMonthlySubscriptionPrice.toFixed(2))
@@ -59641,6 +59647,14 @@ function useEventManagementController() {
59641
59647
  getEventManagementById: _getEventManagementById,
59642
59648
  deleteEventManagementById: _deleteEventManagementById
59643
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
+ }
59644
59658
  async function add(req, res, next) {
59645
59659
  try {
59646
59660
  const { error, value } = schemaEventManagement.validate(req.body, {
@@ -59652,6 +59666,7 @@ function useEventManagementController() {
59652
59666
  next(new import_node_server_utils185.BadRequestError(messages));
59653
59667
  return;
59654
59668
  }
59669
+ await requireSiteReach(req, value.site);
59655
59670
  const data = await _add(value);
59656
59671
  res.status(201).json(data);
59657
59672
  return;
@@ -59685,6 +59700,7 @@ function useEventManagementController() {
59685
59700
  return;
59686
59701
  }
59687
59702
  const { search, page, limit, site, status, type, startDate, endDate, sort, order } = value;
59703
+ await requireSiteReach(req, site);
59688
59704
  const sortObj = {
59689
59705
  [sort ?? "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
59690
59706
  };
@@ -59719,7 +59735,7 @@ function useEventManagementController() {
59719
59735
  return;
59720
59736
  }
59721
59737
  const { _id } = value;
59722
- const data = await _getEventManagementById(_id);
59738
+ const data = await requireEventReach(req, _id);
59723
59739
  res.status(200).json(data);
59724
59740
  return;
59725
59741
  } catch (error) {
@@ -59741,6 +59757,7 @@ function useEventManagementController() {
59741
59757
  }
59742
59758
  const { _id, ...rest } = value;
59743
59759
  try {
59760
+ await requireEventReach(req, _id);
59744
59761
  const result = await _updateEventManagementById(_id, rest);
59745
59762
  res.status(200).json({ message: result });
59746
59763
  return;
@@ -59762,6 +59779,7 @@ function useEventManagementController() {
59762
59779
  return;
59763
59780
  }
59764
59781
  const { _id } = value;
59782
+ await requireEventReach(req, _id);
59765
59783
  await _deleteEventManagementById(_id);
59766
59784
  res.status(200).json({ message: "Successfully deleted event." });
59767
59785
  return;