@7365admin1/core 3.52.16-staging.265 → 3.52.16-staging.266

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
+ Restore and extend the site scoping on the patrol-log email endpoints.
6
+
7
+ #1967 added a `requireSiteReach` guard to `POST /api/patrol-logs/email`. #1981,
8
+ branched before #1967 landed, rewrote the same controller to add the history
9
+ endpoints and dropped the guard. Neither repo runs its tests in CI, so the e2e
10
+ test #1967 shipped has been failing on `main` unnoticed ever since.
11
+
12
+ All five endpoints now resolve the caller from the session: the two that name a
13
+ site (`send`, `getAll`) check that site, and the three that name a record
14
+ (`resend`, `getById`, `deleteById`) check the site stored on the record. The
15
+ `createdBy` pinning is restored with them, so a send cannot be filed under
16
+ another user's name.
package/dist/index.js CHANGED
@@ -61485,10 +61485,20 @@ function usePatrolEmailController() {
61485
61485
  getById: _getById,
61486
61486
  deleteById: _deleteById
61487
61487
  } = usePatrolEmailService();
61488
+ async function requirePatrolEmailReach(req, site) {
61489
+ await requireSiteReach(req, site);
61490
+ }
61491
+ async function requireRecordReach(req, id) {
61492
+ const record = await _getById(id);
61493
+ await requirePatrolEmailReach(req, record?.site);
61494
+ return record;
61495
+ }
61488
61496
  async function send2(req, res, next) {
61489
- const { error, value } = schemaSendPatrolEmail.validate(req.body, {
61490
- abortEarly: false
61491
- });
61497
+ const actor = await resolveInviteActor(callerId(req));
61498
+ const { error, value } = schemaSendPatrolEmail.validate(
61499
+ { ...req.body, createdBy: { _id: actor.id, name: actor.name } },
61500
+ { abortEarly: false }
61501
+ );
61492
61502
  if (error) {
61493
61503
  const messages = error.details.map((d) => d.message).join(", ");
61494
61504
  import_node_server_utils163.logger.log({ level: "error", message: messages });
@@ -61496,6 +61506,7 @@ function usePatrolEmailController() {
61496
61506
  return;
61497
61507
  }
61498
61508
  try {
61509
+ await requirePatrolEmailReach(req, value.site);
61499
61510
  const cookieHeader = req.headers.cookie;
61500
61511
  const data = await _send({
61501
61512
  site: value.site,
@@ -61539,6 +61550,7 @@ function usePatrolEmailController() {
61539
61550
  return;
61540
61551
  }
61541
61552
  try {
61553
+ await requireRecordReach(req, params.value.id);
61542
61554
  const data = await _resend({
61543
61555
  id: params.value.id,
61544
61556
  createdBy: value.createdBy,
@@ -61566,6 +61578,7 @@ function usePatrolEmailController() {
61566
61578
  return;
61567
61579
  }
61568
61580
  try {
61581
+ await requirePatrolEmailReach(req, value.site);
61569
61582
  res.json(await _getAll(value));
61570
61583
  return;
61571
61584
  } catch (err) {
@@ -61585,7 +61598,7 @@ function usePatrolEmailController() {
61585
61598
  return;
61586
61599
  }
61587
61600
  try {
61588
- res.json({ data: await _getById(value.id) });
61601
+ res.json({ data: await requireRecordReach(req, value.id) });
61589
61602
  return;
61590
61603
  } catch (err) {
61591
61604
  import_node_server_utils163.logger.log({ level: "error", message: `${err.message}` });
@@ -61604,6 +61617,7 @@ function usePatrolEmailController() {
61604
61617
  return;
61605
61618
  }
61606
61619
  try {
61620
+ await requireRecordReach(req, value.id);
61607
61621
  res.json({ message: await _deleteById(value.id) });
61608
61622
  return;
61609
61623
  } catch (err) {