@7365admin1/core 3.48.1-staging.194 → 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.
- package/.changeset/attendance-settings-site-scope.md +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/attendance-settings-scope.e2e.test.mjs +355 -0
- package/test/e2e/harness.mjs +11 -0
|
@@ -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.
|
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;
|