@7365admin1/core 3.48.1-staging.193 → 3.48.1-staging.195

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,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Scope the attendance settings routes to their estate. `GET` and `PUT /api/attendance-settings/site/:site` carried `requireAuth` and nothing more and the controller held no authorization identifier, so any signed-in account on the platform could read and rewrite any estate's attendance settings — turn location capture off, move the clock-in coordinates, or widen the geofence radius so a shift can be clocked in from anywhere. The read also created a default settings row for a site that had none, so an unauthorised read wrote into another estate's data. Reach is now decided from the session, on the site named in the request, before either the read or the write happens.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Scope the bulletin video routes to their estate. `POST /api/bulletin-videos`, the list, the by-id read, the update and the delete carried `requireAuth` and nothing more, so any signed-in account on the platform could publish a video into another client's estate, list that estate's videos, or read, rewrite and delete any video by its id alone. Reach is now decided from the session — on the site named in the request for the write and the list, and on the stored row for the three by-id routes.
package/dist/index.js CHANGED
@@ -40522,6 +40522,9 @@ var import_node_server_utils121 = require("@7365admin1/node-server-utils");
40522
40522
  function useAttendanceSettingsController() {
40523
40523
  const { getAttendanceSettingsBySite: _getAttendanceSettingsBySite } = useAttendanceSettingsService();
40524
40524
  const { updateAttendanceSettings: _updateAttendanceSettings } = useAttendanceSettingsRepository();
40525
+ async function requireAttendanceSettingsReach(req, site) {
40526
+ await requireSiteReach(req, site);
40527
+ }
40525
40528
  async function getAttendanceSettingsBySite(req, res, next) {
40526
40529
  const query2 = { ...req.query, ...req.params };
40527
40530
  const validation = import_joi60.default.object({
@@ -40537,6 +40540,7 @@ function useAttendanceSettingsController() {
40537
40540
  const site = req.params.site ?? "";
40538
40541
  const serviceType = req.query.serviceType ?? "";
40539
40542
  try {
40543
+ await requireAttendanceSettingsReach(req, site);
40540
40544
  const data = await _getAttendanceSettingsBySite(site, serviceType);
40541
40545
  res.json(data);
40542
40546
  return;
@@ -40555,6 +40559,7 @@ function useAttendanceSettingsController() {
40555
40559
  return;
40556
40560
  }
40557
40561
  try {
40562
+ await requireAttendanceSettingsReach(req, payload.site);
40558
40563
  await _updateAttendanceSettings(payload.site, payload);
40559
40564
  res.json({ message: "Attendance settings updated successfully." });
40560
40565
  return;
@@ -68057,6 +68062,14 @@ function useBulletinVideoController() {
68057
68062
  getBulletinVideoById: _getBulletinVideoById,
68058
68063
  deleteBulletinVideoById: _deleteBulletinVideoById
68059
68064
  } = useBulletinVideoRepo();
68065
+ async function requireBulletinVideoReach(req, id) {
68066
+ const video = await _getBulletinVideoById(id);
68067
+ const { canReach } = await siteReachOf(req);
68068
+ if (!await canReach(video)) {
68069
+ throw new import_node_server_utils203.NotFoundError("Bulletin video not found.");
68070
+ }
68071
+ return video;
68072
+ }
68060
68073
  async function add(req, res, next) {
68061
68074
  try {
68062
68075
  const { error, value } = schemaBulletinVideo.validate(req.body, {
@@ -68068,6 +68081,7 @@ function useBulletinVideoController() {
68068
68081
  next(new import_node_server_utils203.BadRequestError(messages));
68069
68082
  return;
68070
68083
  }
68084
+ await requireSiteReach(req, value.site);
68071
68085
  const data = await _add(value);
68072
68086
  res.status(201).json(data);
68073
68087
  return;
@@ -68102,6 +68116,7 @@ function useBulletinVideoController() {
68102
68116
  [sort ?? "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
68103
68117
  };
68104
68118
  try {
68119
+ await requireSiteReach(req, site);
68105
68120
  const data = await _getAll({
68106
68121
  search,
68107
68122
  page,
@@ -68131,7 +68146,7 @@ function useBulletinVideoController() {
68131
68146
  return;
68132
68147
  }
68133
68148
  const { _id } = value;
68134
- const data = await _getBulletinVideoById(_id);
68149
+ const data = await requireBulletinVideoReach(req, _id);
68135
68150
  res.status(200).json(data);
68136
68151
  return;
68137
68152
  } catch (error) {
@@ -68153,6 +68168,7 @@ function useBulletinVideoController() {
68153
68168
  return;
68154
68169
  }
68155
68170
  try {
68171
+ await requireBulletinVideoReach(req, _id);
68156
68172
  const result = await _updateBulletinVideoById(_id, req.body);
68157
68173
  res.status(200).json({ message: result });
68158
68174
  return;
@@ -68174,6 +68190,7 @@ function useBulletinVideoController() {
68174
68190
  return;
68175
68191
  }
68176
68192
  const { _id } = value;
68193
+ await requireBulletinVideoReach(req, _id);
68177
68194
  await _deleteBulletinVideoById(_id);
68178
68195
  res.status(200).json({ message: "Successfully deleted bulletin video." });
68179
68196
  return;