@7365admin1/core 3.64.3-staging.286 → 3.64.3-staging.288

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,17 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Use the organisation the app asks for when loading a user's membership.
6
+
7
+ Every mobile app loads its user's role through
8
+ `GET /api/members/user/:id/app/:type?org=<org>`, and `getByUserIdType` ignored
9
+ `org`, answering with the first membership of that app type it found. A person
10
+ in more than one organisation could therefore be handed another organisation's
11
+ membership in the app they were using.
12
+
13
+ It now prefers a LIVE membership in the requested organisation. When there is
14
+ none there (or only a removed one), or no valid `org` is sent, it answers exactly
15
+ as before, so no caller that received a membership now receives "not found", and
16
+ a removed membership never wins over a live one. Login and the other internal
17
+ uses of the repository lookup are unchanged.
@@ -0,0 +1,16 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Stop refusing Site Settings saves that send back `metadata.residentAppModulesEffective`.
6
+
7
+ `GET /api/sites/:id` attaches the derived `residentAppModulesEffective` to
8
+ `metadata` on every read, and the Site Settings screens save by sending the
9
+ metadata they read straight back. `updateSiteSchema` does not allow that key, so
10
+ `PATCH /api/sites/id/:id` refused the whole save with "is not allowed" — the
11
+ resident-app configuration panel, the HID QR code pass and the HID face-reader
12
+ toggle all failed.
13
+
14
+ `updateById` now drops the derived key before validating. It is never stored and
15
+ is recomputed on the next read, so nothing is lost; every stored key, including
16
+ `residentAppModules`, is validated and saved exactly as before.
package/dist/index.js CHANGED
@@ -27949,9 +27949,12 @@ function useMemberController() {
27949
27949
  }
27950
27950
  const user = req.params.id;
27951
27951
  const type = req.params.type;
27952
+ const org = typeof req.query.org === "string" && /^[0-9a-fA-F]{24}$/.test(req.query.org) ? req.query.org : "";
27952
27953
  try {
27953
27954
  await requireSelfOrPlatformStaff(req, user, { resource: "members", action: "view-members" });
27954
- const data = await _getByUserIdType(user, type);
27955
+ const inOrg = org ? await _getByUserIdTypeOrg(user, type, org).catch(() => null) : null;
27956
+ const liveInOrg = inOrg && inOrg.status !== "deleted" && !inOrg.deletedAt ? inOrg : null;
27957
+ const data = liveInOrg ?? await _getByUserIdType(user, type);
27955
27958
  res.json(data);
27956
27959
  return;
27957
27960
  } catch (error2) {
@@ -38517,6 +38520,13 @@ function residentAppModulesAboveCeiling(orgModules, requested) {
38517
38520
  function residentAppModulesAboveCeilingMessage(rejected) {
38518
38521
  return `This client has not been given ${rejected.join(", ")} in the resident app, so a site cannot switch it on. Ask Seven365 to add it to the organisation first.`;
38519
38522
  }
38523
+ function withoutDerivedSiteMetadata(metadata) {
38524
+ if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
38525
+ return metadata;
38526
+ }
38527
+ const { residentAppModulesEffective: _derived, ...stored } = metadata;
38528
+ return stored;
38529
+ }
38520
38530
  function asModules(value) {
38521
38531
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
38522
38532
  }
@@ -38704,8 +38714,9 @@ function useSiteController() {
38704
38714
  }
38705
38715
  async function updateById(req, res, next) {
38706
38716
  try {
38717
+ const body = req.body?.metadata ? { ...req.body, metadata: withoutDerivedSiteMetadata(req.body.metadata) } : req.body;
38707
38718
  const { error, value } = updateSiteSchema.validate(
38708
- { _id: req.params.id, ...req.body },
38719
+ { _id: req.params.id, ...body },
38709
38720
  { abortEarly: false }
38710
38721
  );
38711
38722
  if (error) {