@7365admin1/core 3.55.0 → 3.56.0
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/CHANGELOG.md +37 -0
- package/dist/index.js +4418 -4361
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/e2e/onboarding-org-save-diagnosis.e2e.test.mjs +76 -3
- package/test/role-scope-separation.test.mjs +195 -0
- package/test/role-scope.test.mjs +55 -3
- package/tools/role-scope-lockout-check/check.js +316 -0
- package/tools/role-scope-lockout-check/platform-only-permissions.json +21 -0
- package/tools/role-scope-lockout-check/srv.js +39 -0
package/dist/index.mjs
CHANGED
|
@@ -18696,6 +18696,53 @@ function useRoleService() {
|
|
|
18696
18696
|
return { deleteRole, getDeletionPreview, deleteWithReassignments };
|
|
18697
18697
|
}
|
|
18698
18698
|
|
|
18699
|
+
// src/utils/role-scope.util.ts
|
|
18700
|
+
import { UnauthorizedError as UnauthorizedError4 } from "@7365admin1/node-server-utils";
|
|
18701
|
+
function roleScope(role) {
|
|
18702
|
+
if ((role?.type ?? "") === PLATFORM_STAFF_ROLE_TYPE)
|
|
18703
|
+
return "platform";
|
|
18704
|
+
return role?.org?.toString() ? "client" : "client-template";
|
|
18705
|
+
}
|
|
18706
|
+
var PLATFORM_ONLY_RESOURCES = [
|
|
18707
|
+
"organizations",
|
|
18708
|
+
"promo-codes",
|
|
18709
|
+
"subscriptions",
|
|
18710
|
+
"sp-approvals",
|
|
18711
|
+
"marketplace-vendors",
|
|
18712
|
+
"platform-terms",
|
|
18713
|
+
"activity-history"
|
|
18714
|
+
];
|
|
18715
|
+
var PLATFORM_ONLY_PERMISSIONS = new Set(
|
|
18716
|
+
PLATFORM_ONLY_RESOURCES.flatMap(
|
|
18717
|
+
(resource) => (CONSOLE_PERMISSIONS[resource] ?? []).map(
|
|
18718
|
+
(action) => `${resource}:${action}`
|
|
18719
|
+
)
|
|
18720
|
+
)
|
|
18721
|
+
);
|
|
18722
|
+
function platformPermissionsAdded(next, held) {
|
|
18723
|
+
const already = new Set(held ?? []);
|
|
18724
|
+
return (next ?? []).filter(
|
|
18725
|
+
(permission) => PLATFORM_ONLY_PERMISSIONS.has(permission) && !already.has(permission)
|
|
18726
|
+
);
|
|
18727
|
+
}
|
|
18728
|
+
function requireNoPlatformGrant(role, next) {
|
|
18729
|
+
if (roleScope(role) === "platform")
|
|
18730
|
+
return;
|
|
18731
|
+
const added = platformPermissionsAdded(next, role?.permissions);
|
|
18732
|
+
if (added.length === 0)
|
|
18733
|
+
return;
|
|
18734
|
+
throw new UnauthorizedError4(
|
|
18735
|
+
"These are Seven365 console permissions and cannot be granted on a client role: " + added.join(", ")
|
|
18736
|
+
);
|
|
18737
|
+
}
|
|
18738
|
+
function refuseSharedClientTemplate(role) {
|
|
18739
|
+
if (roleScope(role) !== "client-template")
|
|
18740
|
+
return;
|
|
18741
|
+
throw new UnauthorizedError4(
|
|
18742
|
+
"This role is shared by every client that was invited with it and cannot be changed here."
|
|
18743
|
+
);
|
|
18744
|
+
}
|
|
18745
|
+
|
|
18699
18746
|
// src/controllers/role.controller.ts
|
|
18700
18747
|
async function requireRoleOrg(req, org) {
|
|
18701
18748
|
const orgId = org?.toString() ?? "";
|
|
@@ -18710,6 +18757,10 @@ async function requireRoleRead(req, roleId, org) {
|
|
|
18710
18757
|
return;
|
|
18711
18758
|
await requireRoleOrg(req, org);
|
|
18712
18759
|
}
|
|
18760
|
+
async function requireRoleWrite(req, role) {
|
|
18761
|
+
refuseSharedClientTemplate(role);
|
|
18762
|
+
await requireRoleOrg(req, role?.org);
|
|
18763
|
+
}
|
|
18713
18764
|
function useRoleController() {
|
|
18714
18765
|
const {
|
|
18715
18766
|
addRole: _createRole,
|
|
@@ -18747,6 +18798,10 @@ function useRoleController() {
|
|
|
18747
18798
|
if (payload.org) {
|
|
18748
18799
|
await requireOrgReach(req, payload.org);
|
|
18749
18800
|
}
|
|
18801
|
+
requireNoPlatformGrant(
|
|
18802
|
+
{ type: payload.type, org: payload.org, permissions: [] },
|
|
18803
|
+
payload.permissions
|
|
18804
|
+
);
|
|
18750
18805
|
const role = await _createRole(payload);
|
|
18751
18806
|
res.status(201).json({ message: "Successfully created role.", data: { role } });
|
|
18752
18807
|
return;
|
|
@@ -18850,7 +18905,8 @@ function useRoleController() {
|
|
|
18850
18905
|
const existing = await _getRoleById(_id);
|
|
18851
18906
|
if (!existing)
|
|
18852
18907
|
throw new NotFoundError14("Role not found.");
|
|
18853
|
-
await
|
|
18908
|
+
await requireRoleWrite(req, existing);
|
|
18909
|
+
requireNoPlatformGrant(existing, permissions);
|
|
18854
18910
|
const role = await _updateRole(_id, { name, permissions });
|
|
18855
18911
|
res.json({ message: "Successfully updated role.", data: { role } });
|
|
18856
18912
|
return;
|
|
@@ -18878,7 +18934,8 @@ function useRoleController() {
|
|
|
18878
18934
|
const existing = await _getRoleById(_id);
|
|
18879
18935
|
if (!existing)
|
|
18880
18936
|
throw new NotFoundError14("Role not found.");
|
|
18881
|
-
await
|
|
18937
|
+
await requireRoleWrite(req, existing);
|
|
18938
|
+
requireNoPlatformGrant(existing, permissions);
|
|
18882
18939
|
await _updatePermissionsById(_id, permissions);
|
|
18883
18940
|
res.json({ message: "Successfully updated role permissions." });
|
|
18884
18941
|
return;
|
|
@@ -18901,7 +18958,7 @@ function useRoleController() {
|
|
|
18901
18958
|
const existing = await _getRoleById(_id);
|
|
18902
18959
|
if (!existing)
|
|
18903
18960
|
throw new NotFoundError14("Role not found.");
|
|
18904
|
-
await
|
|
18961
|
+
await requireRoleWrite(req, existing);
|
|
18905
18962
|
const message = await _deleteRole(_id);
|
|
18906
18963
|
res.json({ message });
|
|
18907
18964
|
return;
|
|
@@ -18957,7 +19014,7 @@ function useRoleController() {
|
|
|
18957
19014
|
const existing = await _getRoleById(req.params.id);
|
|
18958
19015
|
if (!existing)
|
|
18959
19016
|
throw new NotFoundError14("Role not found.");
|
|
18960
|
-
await
|
|
19017
|
+
await requireRoleWrite(req, existing);
|
|
18961
19018
|
const message = await _deleteWithReassignments(
|
|
18962
19019
|
req.params.id,
|
|
18963
19020
|
req.body.reassignments
|
|
@@ -18990,12 +19047,12 @@ import { BadRequestError as BadRequestError49, logger as logger33 } from "@7365a
|
|
|
18990
19047
|
// src/services/member.service.ts
|
|
18991
19048
|
import {
|
|
18992
19049
|
BadRequestError as BadRequestError41,
|
|
18993
|
-
UnauthorizedError as
|
|
19050
|
+
UnauthorizedError as UnauthorizedError5,
|
|
18994
19051
|
useAtlas as useAtlas27
|
|
18995
19052
|
} from "@7365admin1/node-server-utils";
|
|
18996
19053
|
async function requireStaffCaller(callerId5, what) {
|
|
18997
19054
|
if (!await isSuperAdmin(callerId5)) {
|
|
18998
|
-
throw new
|
|
19055
|
+
throw new UnauthorizedError5(
|
|
18999
19056
|
`Only Seven365 staff can ${what}.`
|
|
19000
19057
|
);
|
|
19001
19058
|
}
|
|
@@ -19212,14 +19269,14 @@ function useMemberService() {
|
|
|
19212
19269
|
}
|
|
19213
19270
|
|
|
19214
19271
|
// src/utils/site-reach.util.ts
|
|
19215
|
-
import { useAtlas as useAtlas34, UnauthorizedError as
|
|
19272
|
+
import { useAtlas as useAtlas34, UnauthorizedError as UnauthorizedError7 } from "@7365admin1/node-server-utils";
|
|
19216
19273
|
import { ObjectId as ObjectId47 } from "mongodb";
|
|
19217
19274
|
|
|
19218
19275
|
// src/services/camera-view.service.ts
|
|
19219
19276
|
import {
|
|
19220
19277
|
BadRequestError as BadRequestError48,
|
|
19221
19278
|
NotFoundError as NotFoundError16,
|
|
19222
|
-
UnauthorizedError as
|
|
19279
|
+
UnauthorizedError as UnauthorizedError6,
|
|
19223
19280
|
logger as logger32,
|
|
19224
19281
|
useAtlas as useAtlas33,
|
|
19225
19282
|
useCache as useCache19
|
|
@@ -25666,7 +25723,7 @@ function useCameraViewService() {
|
|
|
25666
25723
|
}
|
|
25667
25724
|
async function authorizeCamera(params) {
|
|
25668
25725
|
if (!params.userId || !ObjectId46.isValid(params.userId)) {
|
|
25669
|
-
throw new
|
|
25726
|
+
throw new UnauthorizedError6("Not signed in.");
|
|
25670
25727
|
}
|
|
25671
25728
|
if (!ObjectId46.isValid(params.cameraId)) {
|
|
25672
25729
|
throw new BadRequestError48("Invalid camera id.");
|
|
@@ -25695,7 +25752,7 @@ function useCameraViewService() {
|
|
|
25695
25752
|
memberships
|
|
25696
25753
|
);
|
|
25697
25754
|
if (!hasAnyPermission(permissions, params.permissions)) {
|
|
25698
|
-
throw new
|
|
25755
|
+
throw new UnauthorizedError6(
|
|
25699
25756
|
"You do not have permission to use this camera."
|
|
25700
25757
|
);
|
|
25701
25758
|
}
|
|
@@ -25803,7 +25860,7 @@ function useCameraViewService() {
|
|
|
25803
25860
|
}
|
|
25804
25861
|
async function entitleSite(params) {
|
|
25805
25862
|
if (!params.userId || !ObjectId46.isValid(params.userId)) {
|
|
25806
|
-
throw new
|
|
25863
|
+
throw new UnauthorizedError6("Not signed in.");
|
|
25807
25864
|
}
|
|
25808
25865
|
if (!ObjectId46.isValid(params.siteId)) {
|
|
25809
25866
|
throw new BadRequestError48("Invalid site id.");
|
|
@@ -25835,7 +25892,7 @@ function useCameraViewService() {
|
|
|
25835
25892
|
);
|
|
25836
25893
|
const required = params.permissions ?? CAMERA_VIEW_PERMISSIONS;
|
|
25837
25894
|
if (!hasAnyPermission(permissions, required)) {
|
|
25838
|
-
throw new
|
|
25895
|
+
throw new UnauthorizedError6(
|
|
25839
25896
|
params.message ?? (required === CAMERA_VIEW_PERMISSIONS ? "You do not have permission to view these cameras." : "You do not have permission to set up cameras on this site.")
|
|
25840
25897
|
);
|
|
25841
25898
|
}
|
|
@@ -26244,7 +26301,7 @@ function idText(value) {
|
|
|
26244
26301
|
async function requireSiteReach(req, site, permission) {
|
|
26245
26302
|
const siteId = site?.toString?.() ?? "";
|
|
26246
26303
|
if (!siteId)
|
|
26247
|
-
throw new
|
|
26304
|
+
throw new UnauthorizedError7("Not authorized.");
|
|
26248
26305
|
const actor = await resolveInviteActor(callerId(req));
|
|
26249
26306
|
if (staffMayBypass(actor))
|
|
26250
26307
|
return;
|
|
@@ -27230,7 +27287,7 @@ function useVerificationController() {
|
|
|
27230
27287
|
// src/controllers/file.controller.ts
|
|
27231
27288
|
import {
|
|
27232
27289
|
BadRequestError as BadRequestError51,
|
|
27233
|
-
UnauthorizedError as
|
|
27290
|
+
UnauthorizedError as UnauthorizedError8,
|
|
27234
27291
|
logger as logger35
|
|
27235
27292
|
} from "@7365admin1/node-server-utils";
|
|
27236
27293
|
import Joi27 from "joi";
|
|
@@ -27259,7 +27316,7 @@ async function requireFileDelete(req, file) {
|
|
|
27259
27316
|
return;
|
|
27260
27317
|
const caller = callerId(req);
|
|
27261
27318
|
if (!caller)
|
|
27262
|
-
throw new
|
|
27319
|
+
throw new UnauthorizedError8("Not authorized.");
|
|
27263
27320
|
if (caller === ownerId)
|
|
27264
27321
|
return;
|
|
27265
27322
|
const [me, owner] = await Promise.all([
|
|
@@ -27275,7 +27332,7 @@ async function requireFileDelete(req, file) {
|
|
|
27275
27332
|
})) {
|
|
27276
27333
|
return;
|
|
27277
27334
|
}
|
|
27278
|
-
throw new
|
|
27335
|
+
throw new UnauthorizedError8("Not authorized.");
|
|
27279
27336
|
}
|
|
27280
27337
|
function useFileController() {
|
|
27281
27338
|
const { createFile, deleteFile: _deleteFile } = useFileService();
|
|
@@ -27348,7 +27405,7 @@ import {
|
|
|
27348
27405
|
BadRequestError as BadRequestError55,
|
|
27349
27406
|
logger as logger38,
|
|
27350
27407
|
NotFoundError as NotFoundError17,
|
|
27351
|
-
UnauthorizedError as
|
|
27408
|
+
UnauthorizedError as UnauthorizedError9
|
|
27352
27409
|
} from "@7365admin1/node-server-utils";
|
|
27353
27410
|
import Joi31 from "joi";
|
|
27354
27411
|
|
|
@@ -28621,7 +28678,7 @@ function useOrgController() {
|
|
|
28621
28678
|
try {
|
|
28622
28679
|
const createdBy = callerId(req);
|
|
28623
28680
|
if (!createdBy)
|
|
28624
|
-
throw new
|
|
28681
|
+
throw new UnauthorizedError9("Not authorized.");
|
|
28625
28682
|
const _id = await _add({ ...req.body, createdBy });
|
|
28626
28683
|
const data = await _getById(_id);
|
|
28627
28684
|
res.status(201).json({
|
|
@@ -31122,7 +31179,7 @@ function useSubscriptionService() {
|
|
|
31122
31179
|
import Joi36 from "joi";
|
|
31123
31180
|
import {
|
|
31124
31181
|
BadRequestError as BadRequestError71,
|
|
31125
|
-
UnauthorizedError as
|
|
31182
|
+
UnauthorizedError as UnauthorizedError10,
|
|
31126
31183
|
logger as logger48
|
|
31127
31184
|
} from "@7365admin1/node-server-utils";
|
|
31128
31185
|
|
|
@@ -31543,7 +31600,7 @@ function useSubscriptionController() {
|
|
|
31543
31600
|
try {
|
|
31544
31601
|
const subscription = await _getSubscriptionById(subscriptionId);
|
|
31545
31602
|
if (!subscription) {
|
|
31546
|
-
throw new
|
|
31603
|
+
throw new UnauthorizedError10("Not authorized.");
|
|
31547
31604
|
}
|
|
31548
31605
|
await requireOrgAccess(req, subscription.org?.toString());
|
|
31549
31606
|
const _res = await _updateSubscriptionSeats({
|
|
@@ -41875,7 +41932,7 @@ function useCustomerSiteService() {
|
|
|
41875
41932
|
import Joi59 from "joi";
|
|
41876
41933
|
import {
|
|
41877
41934
|
BadRequestError as BadRequestError107,
|
|
41878
|
-
UnauthorizedError as
|
|
41935
|
+
UnauthorizedError as UnauthorizedError11,
|
|
41879
41936
|
logger as logger78
|
|
41880
41937
|
} from "@7365admin1/node-server-utils";
|
|
41881
41938
|
async function requireEitherOrg(req, ...orgs) {
|
|
@@ -41884,7 +41941,7 @@ async function requireEitherOrg(req, ...orgs) {
|
|
|
41884
41941
|
if (staffMayBypass(actor))
|
|
41885
41942
|
return;
|
|
41886
41943
|
if (wanted.length === 0 || !wanted.some((org) => actor.orgIds.includes(org))) {
|
|
41887
|
-
throw new
|
|
41944
|
+
throw new UnauthorizedError11("Not authorized.");
|
|
41888
41945
|
}
|
|
41889
41946
|
}
|
|
41890
41947
|
function useCustomerSiteController() {
|
|
@@ -45096,7 +45153,7 @@ import {
|
|
|
45096
45153
|
BadRequestError as BadRequestError121,
|
|
45097
45154
|
InternalServerError as InternalServerError42,
|
|
45098
45155
|
NotFoundError as NotFoundError34,
|
|
45099
|
-
UnauthorizedError as
|
|
45156
|
+
UnauthorizedError as UnauthorizedError12,
|
|
45100
45157
|
logger as logger90
|
|
45101
45158
|
} from "@7365admin1/node-server-utils";
|
|
45102
45159
|
|
|
@@ -48630,8 +48687,8 @@ function useHidAmicoService() {
|
|
|
48630
48687
|
await siteAccess.authorizeSite({ siteId, userId: value.userId, permissions });
|
|
48631
48688
|
}
|
|
48632
48689
|
} catch (error) {
|
|
48633
|
-
if (error instanceof
|
|
48634
|
-
throw new
|
|
48690
|
+
if (error instanceof UnauthorizedError12) {
|
|
48691
|
+
throw new UnauthorizedError12("You do not have permission to manage HID access at this site.");
|
|
48635
48692
|
}
|
|
48636
48693
|
throw error;
|
|
48637
48694
|
}
|
|
@@ -48655,7 +48712,7 @@ function useHidAmicoService() {
|
|
|
48655
48712
|
try {
|
|
48656
48713
|
await authorizeSiteForCaller(String(reader.site || ""), userId);
|
|
48657
48714
|
} catch (error) {
|
|
48658
|
-
if (error instanceof
|
|
48715
|
+
if (error instanceof UnauthorizedError12)
|
|
48659
48716
|
throw error;
|
|
48660
48717
|
throw new NotFoundError34(HID_READER_NOT_FOUND);
|
|
48661
48718
|
}
|
|
@@ -48707,10 +48764,10 @@ function useHidAmicoService() {
|
|
|
48707
48764
|
async function assertUserReaderPermission(reader, userId, options = {}) {
|
|
48708
48765
|
const permission = await getReaderPermissionForUser(reader, userId);
|
|
48709
48766
|
if (!permission.granted) {
|
|
48710
|
-
throw new
|
|
48767
|
+
throw new UnauthorizedError12("You do not have HID access permission for this reader.");
|
|
48711
48768
|
}
|
|
48712
48769
|
if (options.intercom && !permission.intercom) {
|
|
48713
|
-
throw new
|
|
48770
|
+
throw new UnauthorizedError12("You do not have HID intercom permission for this reader.");
|
|
48714
48771
|
}
|
|
48715
48772
|
return permission;
|
|
48716
48773
|
}
|
|
@@ -50048,10 +50105,10 @@ function useHidAmicoService() {
|
|
|
50048
50105
|
const hasActiveMembership = memberships.some((membership) => membership.status !== "deleted" && membership.status !== "inactive");
|
|
50049
50106
|
const resolvedIssuer = issuer || (hasResidentMembership ? "resident" : "property_management");
|
|
50050
50107
|
if (resolvedIssuer === "resident" && !hasResidentMembership) {
|
|
50051
|
-
throw new
|
|
50108
|
+
throw new UnauthorizedError12("Only a Resident account can issue a Resident visitor QR code.");
|
|
50052
50109
|
}
|
|
50053
50110
|
if (resolvedIssuer === "property_management" && !hasActiveMembership) {
|
|
50054
|
-
throw new
|
|
50111
|
+
throw new UnauthorizedError12("Only a site Property Management account can issue this visitor QR code.");
|
|
50055
50112
|
}
|
|
50056
50113
|
const configuredGateIds = site?.metadata?.hidQrCodePass?.qrGatePermissions?.[resolvedIssuer === "resident" ? "resident" : "propertyManagement"] || [];
|
|
50057
50114
|
const gateReaderIds = configuredGateIds.filter((readerId) => typeof readerId === "string" && /^[a-f0-9]{24}$/i.test(readerId)).map(String);
|
|
@@ -52644,7 +52701,7 @@ function useVisitorTransactionService() {
|
|
|
52644
52701
|
import Joi68 from "joi";
|
|
52645
52702
|
import moment5 from "moment-timezone";
|
|
52646
52703
|
import { ObjectId as ObjectId90 } from "mongodb";
|
|
52647
|
-
import { BadRequestError as BadRequestError124, NotFoundError as NotFoundError36, InternalServerError as InternalServerError44, UnauthorizedError as
|
|
52704
|
+
import { BadRequestError as BadRequestError124, NotFoundError as NotFoundError36, InternalServerError as InternalServerError44, UnauthorizedError as UnauthorizedError13, logger as logger94 } from "@7365admin1/node-server-utils";
|
|
52648
52705
|
|
|
52649
52706
|
// src/models/visitor-invite.model.ts
|
|
52650
52707
|
import Joi66 from "joi";
|
|
@@ -57428,7 +57485,7 @@ function useVisitorTransactionController() {
|
|
|
57428
57485
|
}
|
|
57429
57486
|
const inviterUserId = callerId(req);
|
|
57430
57487
|
if (!inviterUserId) {
|
|
57431
|
-
next(new
|
|
57488
|
+
next(new UnauthorizedError13("Not authorized."));
|
|
57432
57489
|
return;
|
|
57433
57490
|
}
|
|
57434
57491
|
try {
|
|
@@ -57992,7 +58049,7 @@ function useGuestManagementController() {
|
|
|
57992
58049
|
// src/controllers/person.controller.ts
|
|
57993
58050
|
import Joi71 from "joi";
|
|
57994
58051
|
import { BadRequestError as BadRequestError127, logger as logger97 } from "@7365admin1/node-server-utils";
|
|
57995
|
-
import { NotFoundError as NotFoundError37, UnauthorizedError as
|
|
58052
|
+
import { NotFoundError as NotFoundError37, UnauthorizedError as UnauthorizedError14 } from "@7365admin1/node-server-utils";
|
|
57996
58053
|
function usePersonController() {
|
|
57997
58054
|
const {
|
|
57998
58055
|
getAll: _getAll,
|
|
@@ -58026,7 +58083,7 @@ function usePersonController() {
|
|
|
58026
58083
|
}
|
|
58027
58084
|
const org = person.org?.toString() ?? "";
|
|
58028
58085
|
if (!org || !actor.orgIds.includes(org)) {
|
|
58029
|
-
throw new
|
|
58086
|
+
throw new UnauthorizedError14("Not authorized.");
|
|
58030
58087
|
}
|
|
58031
58088
|
return actor;
|
|
58032
58089
|
}
|
|
@@ -58152,7 +58209,7 @@ function usePersonController() {
|
|
|
58152
58209
|
});
|
|
58153
58210
|
} else if (org) {
|
|
58154
58211
|
if (!actor.orgIds.includes(org)) {
|
|
58155
|
-
throw new
|
|
58212
|
+
throw new UnauthorizedError14("Not authorized.");
|
|
58156
58213
|
}
|
|
58157
58214
|
} else {
|
|
58158
58215
|
orgs = actor.orgIds;
|
|
@@ -62472,7 +62529,7 @@ function useSiteFacilityService() {
|
|
|
62472
62529
|
import {
|
|
62473
62530
|
BadRequestError as BadRequestError149,
|
|
62474
62531
|
NotFoundError as NotFoundError43,
|
|
62475
|
-
UnauthorizedError as
|
|
62532
|
+
UnauthorizedError as UnauthorizedError15,
|
|
62476
62533
|
logger as logger116
|
|
62477
62534
|
} from "@7365admin1/node-server-utils";
|
|
62478
62535
|
import Joi83 from "joi";
|
|
@@ -62559,7 +62616,7 @@ function useSiteFacilityController() {
|
|
|
62559
62616
|
} else {
|
|
62560
62617
|
const { actor } = await siteReachOf(req);
|
|
62561
62618
|
if (!actor.isSuperAdmin)
|
|
62562
|
-
throw new
|
|
62619
|
+
throw new UnauthorizedError15("Not authorized.");
|
|
62563
62620
|
}
|
|
62564
62621
|
const data = await _getAll({
|
|
62565
62622
|
search,
|
|
@@ -65594,7 +65651,7 @@ function useBulletinBoardService() {
|
|
|
65594
65651
|
import {
|
|
65595
65652
|
BadRequestError as BadRequestError158,
|
|
65596
65653
|
NotFoundError as NotFoundError51,
|
|
65597
|
-
UnauthorizedError as
|
|
65654
|
+
UnauthorizedError as UnauthorizedError16,
|
|
65598
65655
|
logger as logger125
|
|
65599
65656
|
} from "@7365admin1/node-server-utils";
|
|
65600
65657
|
import Joi91 from "joi";
|
|
@@ -65630,7 +65687,7 @@ function useBulletinBoardController() {
|
|
|
65630
65687
|
} else {
|
|
65631
65688
|
const { canReach } = await siteReachOf(req);
|
|
65632
65689
|
if (!await canReach(scopeOf(value))) {
|
|
65633
|
-
throw new
|
|
65690
|
+
throw new UnauthorizedError16("Not authorized.");
|
|
65634
65691
|
}
|
|
65635
65692
|
}
|
|
65636
65693
|
const data = await _add(value);
|
|
@@ -66187,7 +66244,7 @@ import { BadRequestError as BadRequestError164, logger as logger131 } from "@736
|
|
|
66187
66244
|
import {
|
|
66188
66245
|
BadRequestError as BadRequestError163,
|
|
66189
66246
|
logger as logger130,
|
|
66190
|
-
UnauthorizedError as
|
|
66247
|
+
UnauthorizedError as UnauthorizedError17,
|
|
66191
66248
|
useAtlas as useAtlas89
|
|
66192
66249
|
} from "@7365admin1/node-server-utils";
|
|
66193
66250
|
|
|
@@ -66571,7 +66628,7 @@ function useSiteBillingItemService() {
|
|
|
66571
66628
|
function assertUnitAtSite(buildingUnit, site) {
|
|
66572
66629
|
const siteId = site?.toString?.() ?? "";
|
|
66573
66630
|
if (!siteId || (buildingUnit?.site?.toString() ?? "") !== siteId) {
|
|
66574
|
-
throw new
|
|
66631
|
+
throw new UnauthorizedError17("Not authorized.");
|
|
66575
66632
|
}
|
|
66576
66633
|
}
|
|
66577
66634
|
async function add(value) {
|
|
@@ -66742,7 +66799,7 @@ function useSiteBillingItemService() {
|
|
|
66742
66799
|
message: error.message
|
|
66743
66800
|
});
|
|
66744
66801
|
await session.abortTransaction();
|
|
66745
|
-
if (error instanceof BadRequestError163 || error instanceof
|
|
66802
|
+
if (error instanceof BadRequestError163 || error instanceof UnauthorizedError17) {
|
|
66746
66803
|
throw error;
|
|
66747
66804
|
}
|
|
66748
66805
|
throw new BadRequestError163("Failed to update Site Billing Item.");
|
|
@@ -68711,7 +68768,7 @@ import Joi99 from "joi";
|
|
|
68711
68768
|
|
|
68712
68769
|
// src/utils/resident-unit.util.ts
|
|
68713
68770
|
import { ObjectId as ObjectId124 } from "mongodb";
|
|
68714
|
-
import { UnauthorizedError as
|
|
68771
|
+
import { UnauthorizedError as UnauthorizedError18, useAtlas as useAtlas95 } from "@7365admin1/node-server-utils";
|
|
68715
68772
|
async function requireOwnUnit(req, site, unitId) {
|
|
68716
68773
|
const actor = await resolveInviteActor(callerId(req));
|
|
68717
68774
|
if (staffMayBypass(actor))
|
|
@@ -68719,7 +68776,7 @@ async function requireOwnUnit(req, site, unitId) {
|
|
|
68719
68776
|
const unit = unitId?.toString?.() ?? "";
|
|
68720
68777
|
const siteId = site?.toString?.() ?? "";
|
|
68721
68778
|
if (!ObjectId124.isValid(unit) || !ObjectId124.isValid(siteId) || !actor.id) {
|
|
68722
|
-
throw new
|
|
68779
|
+
throw new UnauthorizedError18("Not authorized.");
|
|
68723
68780
|
}
|
|
68724
68781
|
const db2 = useAtlas95.getDb();
|
|
68725
68782
|
if (!db2)
|
|
@@ -68731,7 +68788,7 @@ async function requireOwnUnit(req, site, unitId) {
|
|
|
68731
68788
|
status: { $ne: "deleted" }
|
|
68732
68789
|
});
|
|
68733
68790
|
if (!own)
|
|
68734
|
-
throw new
|
|
68791
|
+
throw new UnauthorizedError18("Not authorized.");
|
|
68735
68792
|
}
|
|
68736
68793
|
|
|
68737
68794
|
// src/controllers/site-unit-billing.controller.ts
|
|
@@ -77283,7 +77340,7 @@ function useOnlineFormRepo() {
|
|
|
77283
77340
|
import {
|
|
77284
77341
|
BadRequestError as BadRequestError204,
|
|
77285
77342
|
NotFoundError as NotFoundError71,
|
|
77286
|
-
UnauthorizedError as
|
|
77343
|
+
UnauthorizedError as UnauthorizedError19,
|
|
77287
77344
|
logger as logger169
|
|
77288
77345
|
} from "@7365admin1/node-server-utils";
|
|
77289
77346
|
import Joi122 from "joi";
|
|
@@ -77355,10 +77412,10 @@ function useOnlineFormController() {
|
|
|
77355
77412
|
if (site) {
|
|
77356
77413
|
await requireSiteReach(req, site);
|
|
77357
77414
|
} else if (!staffMayBypass(actor)) {
|
|
77358
|
-
throw new
|
|
77415
|
+
throw new UnauthorizedError19("Not authorized.");
|
|
77359
77416
|
}
|
|
77360
77417
|
if (org && !staffMayBypass(actor) && !actor.orgIds.includes(org)) {
|
|
77361
|
-
throw new
|
|
77418
|
+
throw new UnauthorizedError19("Not authorized.");
|
|
77362
77419
|
}
|
|
77363
77420
|
const data = await _getAll({ search, page, limit, status, org, site });
|
|
77364
77421
|
res.json(data);
|
|
@@ -77423,7 +77480,7 @@ function useOnlineFormController() {
|
|
|
77423
77480
|
if (payload.org) {
|
|
77424
77481
|
const { actor } = await siteReachOf(req);
|
|
77425
77482
|
if (!staffMayBypass(actor) && !actor.orgIds.includes(payload.org)) {
|
|
77426
|
-
throw new
|
|
77483
|
+
throw new UnauthorizedError19("Not authorized.");
|
|
77427
77484
|
}
|
|
77428
77485
|
}
|
|
77429
77486
|
await _updateOnlineFormById(_id, payload);
|
|
@@ -84669,7 +84726,7 @@ import {
|
|
|
84669
84726
|
BadRequestError as BadRequestError229,
|
|
84670
84727
|
NotFoundError as NotFoundError78,
|
|
84671
84728
|
InternalServerError as InternalServerError81,
|
|
84672
|
-
UnauthorizedError as
|
|
84729
|
+
UnauthorizedError as UnauthorizedError20,
|
|
84673
84730
|
useAtlas as useAtlas132,
|
|
84674
84731
|
hashPassword as hashPassword4
|
|
84675
84732
|
} from "@7365admin1/node-server-utils";
|
|
@@ -84938,10 +84995,10 @@ function useVerificationServiceV2() {
|
|
|
84938
84995
|
const org = await getOrgById(orgId);
|
|
84939
84996
|
const actor = await resolveInviteActor(invitedBy);
|
|
84940
84997
|
if (!actor.id) {
|
|
84941
|
-
throw new
|
|
84998
|
+
throw new UnauthorizedError20("Sign in to continue.");
|
|
84942
84999
|
}
|
|
84943
85000
|
if (!staffMayBypass(actor) && !actor.orgIds.includes(orgId)) {
|
|
84944
|
-
throw new
|
|
85001
|
+
throw new UnauthorizedError20(
|
|
84945
85002
|
"You can only invite service providers to your own organisation's sites."
|
|
84946
85003
|
);
|
|
84947
85004
|
}
|
|
@@ -89358,7 +89415,7 @@ import Joi158 from "joi";
|
|
|
89358
89415
|
import { ObjectId as ObjectId179 } from "mongodb";
|
|
89359
89416
|
import {
|
|
89360
89417
|
InternalServerError as InternalServerError93,
|
|
89361
|
-
UnauthorizedError as
|
|
89418
|
+
UnauthorizedError as UnauthorizedError21,
|
|
89362
89419
|
useAtlas as useAtlas146
|
|
89363
89420
|
} from "@7365admin1/node-server-utils";
|
|
89364
89421
|
function db() {
|
|
@@ -89374,7 +89431,7 @@ function asObjectId(value) {
|
|
|
89374
89431
|
function requireCaller(req) {
|
|
89375
89432
|
const id = callerId(req);
|
|
89376
89433
|
if (!id || !ObjectId179.isValid(id)) {
|
|
89377
|
-
throw new
|
|
89434
|
+
throw new UnauthorizedError21("Not authorized.");
|
|
89378
89435
|
}
|
|
89379
89436
|
return id;
|
|
89380
89437
|
}
|
|
@@ -89382,7 +89439,7 @@ function requireSelfId(req, claimed) {
|
|
|
89382
89439
|
const caller = requireCaller(req);
|
|
89383
89440
|
const asked = claimed?.toString?.() ?? "";
|
|
89384
89441
|
if (!asked || asked !== caller) {
|
|
89385
|
-
throw new
|
|
89442
|
+
throw new UnauthorizedError21("Not authorized.");
|
|
89386
89443
|
}
|
|
89387
89444
|
return caller;
|
|
89388
89445
|
}
|
|
@@ -89390,11 +89447,11 @@ async function requireOwnChannel(req, channelId) {
|
|
|
89390
89447
|
const caller = requireCaller(req);
|
|
89391
89448
|
const _id = asObjectId(channelId);
|
|
89392
89449
|
if (!_id)
|
|
89393
|
-
throw new
|
|
89450
|
+
throw new UnauthorizedError21("Not authorized.");
|
|
89394
89451
|
const channel = await db().collection("channel-preloved").findOne({ _id }, { projection: { senderId: 1, receiverId: 1, postId: 1 } });
|
|
89395
89452
|
const participants = [channel?.senderId, channel?.receiverId].map((id) => id?.toString?.() ?? "").filter(Boolean);
|
|
89396
89453
|
if (!channel || !participants.includes(caller)) {
|
|
89397
|
-
throw new
|
|
89454
|
+
throw new UnauthorizedError21("Not authorized.");
|
|
89398
89455
|
}
|
|
89399
89456
|
return { caller, channel };
|
|
89400
89457
|
}
|
|
@@ -89402,10 +89459,10 @@ async function requireOwnChatMessage(req, chatId) {
|
|
|
89402
89459
|
const caller = requireCaller(req);
|
|
89403
89460
|
const _id = asObjectId(chatId);
|
|
89404
89461
|
if (!_id)
|
|
89405
|
-
throw new
|
|
89462
|
+
throw new UnauthorizedError21("Not authorized.");
|
|
89406
89463
|
const message = await db().collection("chat-preloved").findOne({ _id }, { projection: { senderId: 1 } });
|
|
89407
89464
|
if (!message || message.senderId?.toString?.() !== caller) {
|
|
89408
|
-
throw new
|
|
89465
|
+
throw new UnauthorizedError21("Not authorized.");
|
|
89409
89466
|
}
|
|
89410
89467
|
return caller;
|
|
89411
89468
|
}
|
|
@@ -89831,7 +89888,7 @@ function useBidPrelovedService() {
|
|
|
89831
89888
|
// src/controllers/bid-preloved.controller.ts
|
|
89832
89889
|
import {
|
|
89833
89890
|
BadRequestError as BadRequestError252,
|
|
89834
|
-
UnauthorizedError as
|
|
89891
|
+
UnauthorizedError as UnauthorizedError22,
|
|
89835
89892
|
logger as logger212
|
|
89836
89893
|
} from "@7365admin1/node-server-utils";
|
|
89837
89894
|
import Joi161 from "joi";
|
|
@@ -89883,7 +89940,7 @@ function useBidPrelovedController() {
|
|
|
89883
89940
|
const bid = await _getById(params.id);
|
|
89884
89941
|
const seller = await sellerOfPost(bid?.postId);
|
|
89885
89942
|
if (!seller || seller !== caller) {
|
|
89886
|
-
throw new
|
|
89943
|
+
throw new UnauthorizedError22("Not authorized.");
|
|
89887
89944
|
}
|
|
89888
89945
|
const data = await _updateStatus(params.id, body.status);
|
|
89889
89946
|
res.status(200).json(data);
|
|
@@ -89907,7 +89964,7 @@ function useBidPrelovedController() {
|
|
|
89907
89964
|
const data = await _getById(params.id);
|
|
89908
89965
|
const seller = await sellerOfPost(data?.postId);
|
|
89909
89966
|
if (data?.buyerId?.toString?.() !== caller && seller !== caller) {
|
|
89910
|
-
throw new
|
|
89967
|
+
throw new UnauthorizedError22("Not authorized.");
|
|
89911
89968
|
}
|
|
89912
89969
|
res.status(200).json(data);
|
|
89913
89970
|
} catch (error2) {
|
|
@@ -90305,7 +90362,7 @@ function useFormEntryRepo() {
|
|
|
90305
90362
|
import {
|
|
90306
90363
|
BadRequestError as BadRequestError254,
|
|
90307
90364
|
NotFoundError as NotFoundError89,
|
|
90308
|
-
UnauthorizedError as
|
|
90365
|
+
UnauthorizedError as UnauthorizedError23,
|
|
90309
90366
|
logger as logger214
|
|
90310
90367
|
} from "@7365admin1/node-server-utils";
|
|
90311
90368
|
import Joi163 from "joi";
|
|
@@ -90415,7 +90472,7 @@ function useFormEntryController() {
|
|
|
90415
90472
|
} else {
|
|
90416
90473
|
const { actor } = await siteReachOf(req);
|
|
90417
90474
|
if (!actor.isSuperAdmin)
|
|
90418
|
-
throw new
|
|
90475
|
+
throw new UnauthorizedError23("Not authorized.");
|
|
90419
90476
|
}
|
|
90420
90477
|
const data = await _getAll({ search, page, limit, status, org, site });
|
|
90421
90478
|
res.json(data);
|
|
@@ -90466,7 +90523,7 @@ function useFormEntryController() {
|
|
|
90466
90523
|
await requireSiteReach(req, rest.site);
|
|
90467
90524
|
delete rest.userId;
|
|
90468
90525
|
if (isOwner && rest.status && rest.status !== "pending") {
|
|
90469
|
-
throw new
|
|
90526
|
+
throw new UnauthorizedError23("Not authorized.");
|
|
90470
90527
|
}
|
|
90471
90528
|
await _updateFormEntryById(_id, rest);
|
|
90472
90529
|
res.json({ message: "Successfully updated online form." });
|
|
@@ -90523,7 +90580,7 @@ function useFormEntryController() {
|
|
|
90523
90580
|
async function residentFormSubmission(req, res, next) {
|
|
90524
90581
|
const userId = callerId(req);
|
|
90525
90582
|
if (!userId) {
|
|
90526
|
-
next(new
|
|
90583
|
+
next(new UnauthorizedError23("Not authorized."));
|
|
90527
90584
|
return;
|
|
90528
90585
|
}
|
|
90529
90586
|
const payload = { ...req.body, userId };
|
|
@@ -91754,7 +91811,7 @@ function useHidAmicoController() {
|
|
|
91754
91811
|
import {
|
|
91755
91812
|
BadRequestError as BadRequestError257,
|
|
91756
91813
|
logger as logger216,
|
|
91757
|
-
UnauthorizedError as
|
|
91814
|
+
UnauthorizedError as UnauthorizedError24
|
|
91758
91815
|
} from "@7365admin1/node-server-utils";
|
|
91759
91816
|
import Joi165 from "joi";
|
|
91760
91817
|
function usePlatformTermsController() {
|
|
@@ -91770,7 +91827,7 @@ function usePlatformTermsController() {
|
|
|
91770
91827
|
async function requireOwnRecord(req, user, { staffMayRead = false } = {}) {
|
|
91771
91828
|
const id = callerId(req);
|
|
91772
91829
|
if (!id) {
|
|
91773
|
-
throw new
|
|
91830
|
+
throw new UnauthorizedError24("Not authorized.");
|
|
91774
91831
|
}
|
|
91775
91832
|
if (id === user) {
|
|
91776
91833
|
return id;
|
|
@@ -91778,7 +91835,7 @@ function usePlatformTermsController() {
|
|
|
91778
91835
|
if (staffMayRead) {
|
|
91779
91836
|
return await requireConsolePermission(req, "platform-terms", "see-platform-terms");
|
|
91780
91837
|
}
|
|
91781
|
-
throw new
|
|
91838
|
+
throw new UnauthorizedError24("Not authorized.");
|
|
91782
91839
|
}
|
|
91783
91840
|
async function getLatest(_req, res, next) {
|
|
91784
91841
|
try {
|
|
@@ -91984,7 +92041,7 @@ function useConsoleAuditController() {
|
|
|
91984
92041
|
// src/controllers/notification.controller.ts
|
|
91985
92042
|
import {
|
|
91986
92043
|
BadRequestError as BadRequestError259,
|
|
91987
|
-
UnauthorizedError as
|
|
92044
|
+
UnauthorizedError as UnauthorizedError25,
|
|
91988
92045
|
logger as logger218
|
|
91989
92046
|
} from "@7365admin1/node-server-utils";
|
|
91990
92047
|
function useNotificationController() {
|
|
@@ -92002,10 +92059,10 @@ function useNotificationController() {
|
|
|
92002
92059
|
function inboxOwner(req, claimed) {
|
|
92003
92060
|
const caller = callerId5(req);
|
|
92004
92061
|
if (!caller) {
|
|
92005
|
-
throw new
|
|
92062
|
+
throw new UnauthorizedError25("Not authorized.");
|
|
92006
92063
|
}
|
|
92007
92064
|
if (claimed && claimed !== caller) {
|
|
92008
|
-
throw new
|
|
92065
|
+
throw new UnauthorizedError25("Not authorized.");
|
|
92009
92066
|
}
|
|
92010
92067
|
return caller;
|
|
92011
92068
|
}
|
|
@@ -92017,7 +92074,7 @@ function useNotificationController() {
|
|
|
92017
92074
|
}
|
|
92018
92075
|
try {
|
|
92019
92076
|
if (!await isSuperAdmin(callerId5(req))) {
|
|
92020
|
-
throw new
|
|
92077
|
+
throw new UnauthorizedError25("Not authorized.");
|
|
92021
92078
|
}
|
|
92022
92079
|
const inserted = await _addMany(value.to, {
|
|
92023
92080
|
title: value.title,
|