@7365admin1/core 3.47.1-staging.144 → 3.47.1-staging.145
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/access-management-site-scope.md +59 -0
- package/dist/index.d.ts +28 -28
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/access-management-scope.e2e.test.mjs +363 -0
- package/test/e2e/harness.mjs +68 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@7365admin1/core": minor
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Scope the access-management routes to a site the caller can reach.
|
|
6
|
+
|
|
7
|
+
Every route on `/api/access-management` carried `requireAuth` and nothing more.
|
|
8
|
+
`requireAuth` proves a session exists; it makes no organisation or site
|
|
9
|
+
decision. So any signed-in account on the platform — a resident of a different
|
|
10
|
+
estate, a cleaner, anybody with a login — could read another client's
|
|
11
|
+
access-card inventory, its card holders, the residents behind a unit and the
|
|
12
|
+
block/level/unit structure, and could ISSUE a physical NFC card into that
|
|
13
|
+
estate, generate visitor QR passes for it and stamp QR tags onto its cards.
|
|
14
|
+
These are the credentials that open that estate's doors and lifts.
|
|
15
|
+
|
|
16
|
+
Twenty-eight handlers now decide from the site the request already names,
|
|
17
|
+
before any work is done:
|
|
18
|
+
|
|
19
|
+
- from the body — `addPhysicalCard`, `addNonPhysicalCard`, `acknowlegdeCard`,
|
|
20
|
+
`replaceCard`, `assignAccessCardToUnit`, `vmsgenerateQrCodes`,
|
|
21
|
+
`addVisitorAccessCard`;
|
|
22
|
+
- from the query — `allAccessCardsCounts`, `availableAccessCards`,
|
|
23
|
+
`userTypeAccessCards`, `assignedAccessCards`, `assignedAccessCardsByUnit`,
|
|
24
|
+
`accessandLiftCards`, `doorAndLiftDropdown`, `visitorAccessCards`,
|
|
25
|
+
`bulkPhysicalAccessCard`, `getCardDetails`, `allQrTag`,
|
|
26
|
+
`availableCardContractors`, `getBlockLevelAndUnitList`, `getResidents`,
|
|
27
|
+
`userAccessCards`, `uploadTemplate`, `removeTemplate`, `qrCodeList`;
|
|
28
|
+
- from the URL — `getCardReplacement`, `getAccessManagementSettings`, `addQrTag`.
|
|
29
|
+
|
|
30
|
+
The rule is the existing one, `requireSiteReach` -> `entitleSite`: a membership
|
|
31
|
+
pinned to the site, an org-wide membership at the site's owning organisation, or
|
|
32
|
+
an ACTIVE `customer.sites` engagement. The engagement branch is required, not
|
|
33
|
+
incidental — access cards are administered from the security and
|
|
34
|
+
property-management apps, whose users hold no membership in the estate's own
|
|
35
|
+
organisation.
|
|
36
|
+
|
|
37
|
+
The guard writes its own response instead of throwing. Every handler in this
|
|
38
|
+
controller wraps its body in `try { ... } catch { res.status(400|500) }` rather
|
|
39
|
+
than calling `next(error)`, so a thrown `UnauthorizedError`/`NotFoundError`
|
|
40
|
+
would never reach the error handler and would have surfaced as a 400 with the
|
|
41
|
+
guard's message inside it. It is placed AFTER each handler's Joi validation, so
|
|
42
|
+
a malformed or missing site still answers 400 exactly as before, and only a
|
|
43
|
+
well-formed site the caller cannot reach is refused. That refusal is 404 — what
|
|
44
|
+
a site that does not exist already answers — so site ids cannot be enumerated by
|
|
45
|
+
watching the difference.
|
|
46
|
+
|
|
47
|
+
Six routes on the mount are deliberately NOT changed, because they carry no
|
|
48
|
+
site at all and need per-record resolution:
|
|
49
|
+
|
|
50
|
+
- `POST /sign-qr` and `PATCH /visitor-checkout` — both are called by shipped
|
|
51
|
+
mobile clients that cannot update in lockstep
|
|
52
|
+
(`resident-mobile-app src/actions/entrypass.ts:66`, `isecure365-mobile-app
|
|
53
|
+
src/features/visitors/entry-pass.service.ts:175` and `visitor.service.ts:194`).
|
|
54
|
+
- `PATCH /nfc-status`, `PATCH /delete-card`, `POST /card-replacement`,
|
|
55
|
+
`POST /assign-user` — each identifies a card by id and would need the card's
|
|
56
|
+
own site loaded first.
|
|
57
|
+
- `GET /door-access-levels`, `GET /lift-access-levels`, `GET /access-groups` and
|
|
58
|
+
`POST /settings` take an `acm_url` — an access-control device URL — so they
|
|
59
|
+
are a separate question from site reach and were not touched here.
|
package/dist/index.d.ts
CHANGED
|
@@ -6491,35 +6491,35 @@ declare function UseAccessManagementRepo(): {
|
|
|
6491
6491
|
};
|
|
6492
6492
|
|
|
6493
6493
|
declare function useAccessManagementController(): {
|
|
6494
|
-
addPhysicalCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6495
|
-
addNonPhysicalCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6494
|
+
addPhysicalCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6495
|
+
addNonPhysicalCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6496
6496
|
doorAccessLevels: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6497
6497
|
liftAccessLevels: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6498
6498
|
accessGroups: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6499
6499
|
accessManagementSettings: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6500
|
-
allAccessCardsCounts: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6501
|
-
availableAccessCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6502
|
-
userTypeAccessCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6503
|
-
assignedAccessCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6504
|
-
assignedAccessCardsByUnit: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6505
|
-
acknowlegdeCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6506
|
-
accessandLiftCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6507
|
-
replaceCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6500
|
+
allAccessCardsCounts: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6501
|
+
availableAccessCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6502
|
+
userTypeAccessCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6503
|
+
assignedAccessCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6504
|
+
assignedAccessCardsByUnit: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6505
|
+
acknowlegdeCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6506
|
+
accessandLiftCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6507
|
+
replaceCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6508
6508
|
updateNFCStatus: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6509
|
-
doorAndLiftDropdown: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6509
|
+
doorAndLiftDropdown: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6510
6510
|
cardReplacement: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6511
|
-
visitorAccessCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6512
|
-
getCardReplacement: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6513
|
-
getAccessManagementSettings: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6514
|
-
bulkPhysicalAccessCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6515
|
-
assignAccessCardToUnit: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6511
|
+
visitorAccessCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6512
|
+
getCardReplacement: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6513
|
+
getAccessManagementSettings: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6514
|
+
bulkPhysicalAccessCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6515
|
+
assignAccessCardToUnit: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6516
6516
|
deleteCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6517
|
-
getCardDetails: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6518
|
-
addQrTag: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6519
|
-
allQrTag: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6520
|
-
availableCardContractors: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6521
|
-
vmsgenerateQrCodes: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6522
|
-
addVisitorAccessCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6517
|
+
getCardDetails: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6518
|
+
addQrTag: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6519
|
+
allQrTag: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6520
|
+
availableCardContractors: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6521
|
+
vmsgenerateQrCodes: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6522
|
+
addVisitorAccessCard: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6523
6523
|
signQrCode: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6524
6524
|
checkoutVisitor: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6525
6525
|
removeAccessCard: ({ cardNo, staffNo, url, }: {
|
|
@@ -6527,15 +6527,15 @@ declare function useAccessManagementController(): {
|
|
|
6527
6527
|
staffNo: string;
|
|
6528
6528
|
url: string;
|
|
6529
6529
|
}) => Promise<void>;
|
|
6530
|
-
getBlockLevelAndUnitList: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6530
|
+
getBlockLevelAndUnitList: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6531
6531
|
getTransactions: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6532
6532
|
assignMultipleCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6533
6533
|
visitorCheckout: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6534
|
-
uploadTemplate: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6535
|
-
getResidents: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6536
|
-
userAccessCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6537
|
-
removeTemplate: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6538
|
-
qrCodeList: (req: Request, res: Response) => Promise<Response<any, Record<string, any
|
|
6534
|
+
uploadTemplate: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6535
|
+
getResidents: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6536
|
+
userAccessCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6537
|
+
removeTemplate: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6538
|
+
qrCodeList: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6539
6539
|
generateQrCodeWithExpiry: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6540
6540
|
};
|
|
6541
6541
|
|
package/dist/index.js
CHANGED
|
@@ -63787,6 +63787,16 @@ function useAccessManagementSvc() {
|
|
|
63787
63787
|
|
|
63788
63788
|
// src/controllers/access-management.controller.ts
|
|
63789
63789
|
function useAccessManagementController() {
|
|
63790
|
+
const refuseUnreachableSite = async (req, res, site) => {
|
|
63791
|
+
try {
|
|
63792
|
+
await requireSiteReach(req, site);
|
|
63793
|
+
return false;
|
|
63794
|
+
} catch (error) {
|
|
63795
|
+
const status = Number(error?.statusCode) || 401;
|
|
63796
|
+
res.status(status).json({ data: null, message: error.message });
|
|
63797
|
+
return true;
|
|
63798
|
+
}
|
|
63799
|
+
};
|
|
63790
63800
|
const {
|
|
63791
63801
|
addPhysicalCardSvc,
|
|
63792
63802
|
addNonPhysicalCardSvc,
|
|
@@ -63863,6 +63873,8 @@ function useAccessManagementController() {
|
|
|
63863
63873
|
if (error) {
|
|
63864
63874
|
return res.status(400).json({ data: null, message: error.message });
|
|
63865
63875
|
}
|
|
63876
|
+
if (await refuseUnreachableSite(req, res, payload.site))
|
|
63877
|
+
return;
|
|
63866
63878
|
const result = await addPhysicalCardSvc(payload);
|
|
63867
63879
|
return res.status(201).json({
|
|
63868
63880
|
data: result,
|
|
@@ -63931,6 +63943,8 @@ function useAccessManagementController() {
|
|
|
63931
63943
|
if (error) {
|
|
63932
63944
|
throw new Error(`${error.message}`);
|
|
63933
63945
|
}
|
|
63946
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
63947
|
+
return;
|
|
63934
63948
|
const result = await addNonPhysicalCardSvc({
|
|
63935
63949
|
site,
|
|
63936
63950
|
quantity,
|
|
@@ -64031,6 +64045,8 @@ function useAccessManagementController() {
|
|
|
64031
64045
|
if (error) {
|
|
64032
64046
|
throw new Error(`${error.message}`);
|
|
64033
64047
|
}
|
|
64048
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64049
|
+
return;
|
|
64034
64050
|
const result = await allAccessCardsCountsSvc({ site, userType });
|
|
64035
64051
|
return res.status(200).json({ message: "Success", data: result });
|
|
64036
64052
|
} catch (error) {
|
|
@@ -64053,6 +64069,8 @@ function useAccessManagementController() {
|
|
|
64053
64069
|
if (error) {
|
|
64054
64070
|
return res.status(400).json({ message: error.message });
|
|
64055
64071
|
}
|
|
64072
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64073
|
+
return;
|
|
64056
64074
|
const result = await availableAccessCardsSvc({ site, userType, type });
|
|
64057
64075
|
return res.status(200).json({ message: "Success", data: result });
|
|
64058
64076
|
} catch (error) {
|
|
@@ -64091,6 +64109,8 @@ function useAccessManagementController() {
|
|
|
64091
64109
|
if (error) {
|
|
64092
64110
|
return res.status(400).json({ message: error.message });
|
|
64093
64111
|
}
|
|
64112
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64113
|
+
return;
|
|
64094
64114
|
const result = await userTypeAccessCardsSvc({
|
|
64095
64115
|
page,
|
|
64096
64116
|
limit,
|
|
@@ -64136,6 +64156,8 @@ function useAccessManagementController() {
|
|
|
64136
64156
|
if (error) {
|
|
64137
64157
|
return res.status(400).json({ message: error.message });
|
|
64138
64158
|
}
|
|
64159
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64160
|
+
return;
|
|
64139
64161
|
const result = await assignedAccessCardsSvc({
|
|
64140
64162
|
site,
|
|
64141
64163
|
userType,
|
|
@@ -64178,6 +64200,8 @@ function useAccessManagementController() {
|
|
|
64178
64200
|
if (error) {
|
|
64179
64201
|
return res.status(400).json({ message: error.message });
|
|
64180
64202
|
}
|
|
64203
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64204
|
+
return;
|
|
64181
64205
|
const result = await assignedAccessCardsByUnitSvc({
|
|
64182
64206
|
site,
|
|
64183
64207
|
unitId,
|
|
@@ -64205,6 +64229,8 @@ function useAccessManagementController() {
|
|
|
64205
64229
|
if (error) {
|
|
64206
64230
|
return res.status(400).json({ message: error.message });
|
|
64207
64231
|
}
|
|
64232
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64233
|
+
return;
|
|
64208
64234
|
const result = await acknowlegdeCardSvc({ userId, cardId, site });
|
|
64209
64235
|
return res.status(200).json({ message: "Success", data: result });
|
|
64210
64236
|
} catch (error) {
|
|
@@ -64240,6 +64266,8 @@ function useAccessManagementController() {
|
|
|
64240
64266
|
if (error) {
|
|
64241
64267
|
return res.status(400).json({ message: error.message });
|
|
64242
64268
|
}
|
|
64269
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64270
|
+
return;
|
|
64243
64271
|
const result = await accessandLiftCardsSvc({
|
|
64244
64272
|
accessLevel,
|
|
64245
64273
|
liftAccessLevel,
|
|
@@ -64268,6 +64296,8 @@ function useAccessManagementController() {
|
|
|
64268
64296
|
if (error) {
|
|
64269
64297
|
return res.status(400).json({ message: error.message });
|
|
64270
64298
|
}
|
|
64299
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64300
|
+
return;
|
|
64271
64301
|
const result = await replaceCardSvc({ userId, cardId, site, acm_url });
|
|
64272
64302
|
return res.status(200).json({ message: "Success", data: result });
|
|
64273
64303
|
} catch (error) {
|
|
@@ -64314,6 +64344,8 @@ function useAccessManagementController() {
|
|
|
64314
64344
|
if (error) {
|
|
64315
64345
|
return res.status(400).json({ message: error.message });
|
|
64316
64346
|
}
|
|
64347
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64348
|
+
return;
|
|
64317
64349
|
const result = await doorAndLiftDropdownSvc({ site, type, userType });
|
|
64318
64350
|
return res.status(200).json({ message: "Success", data: result });
|
|
64319
64351
|
} catch (error) {
|
|
@@ -64378,6 +64410,8 @@ function useAccessManagementController() {
|
|
|
64378
64410
|
if (error) {
|
|
64379
64411
|
return res.status(400).json({ message: error.message });
|
|
64380
64412
|
}
|
|
64413
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64414
|
+
return;
|
|
64381
64415
|
const result = await visitorAccessCardsSvc({
|
|
64382
64416
|
site,
|
|
64383
64417
|
page,
|
|
@@ -64425,6 +64459,8 @@ function useAccessManagementController() {
|
|
|
64425
64459
|
if (error) {
|
|
64426
64460
|
return res.status(400).json({ message: error.message });
|
|
64427
64461
|
}
|
|
64462
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64463
|
+
return;
|
|
64428
64464
|
const result = await getCardReplacementSvc({
|
|
64429
64465
|
site,
|
|
64430
64466
|
page,
|
|
@@ -64452,6 +64488,8 @@ function useAccessManagementController() {
|
|
|
64452
64488
|
if (error) {
|
|
64453
64489
|
return res.status(400).json({ message: error.message });
|
|
64454
64490
|
}
|
|
64491
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64492
|
+
return;
|
|
64455
64493
|
const result = await getAccessManagementSettingsSvc({ site });
|
|
64456
64494
|
return res.status(200).json({ message: "Success", data: result });
|
|
64457
64495
|
} catch (error) {
|
|
@@ -64468,6 +64506,8 @@ function useAccessManagementController() {
|
|
|
64468
64506
|
throw new Error("File is required!");
|
|
64469
64507
|
const xlsData = await convertBufferFile(req.file.buffer);
|
|
64470
64508
|
const dataJson = JSON.stringify(xlsData);
|
|
64509
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64510
|
+
return;
|
|
64471
64511
|
const result = await bulkPhysicalAccessCardSvc({ dataJson, site });
|
|
64472
64512
|
return res.status(200).json({ message: "Success", data: result });
|
|
64473
64513
|
} catch (error) {
|
|
@@ -64509,6 +64549,8 @@ function useAccessManagementController() {
|
|
|
64509
64549
|
if (error) {
|
|
64510
64550
|
return res.status(400).json({ message: error.message });
|
|
64511
64551
|
}
|
|
64552
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64553
|
+
return;
|
|
64512
64554
|
const result = await assignAccessCardToUnitSvc({
|
|
64513
64555
|
units,
|
|
64514
64556
|
quantity,
|
|
@@ -64557,6 +64599,8 @@ function useAccessManagementController() {
|
|
|
64557
64599
|
if (error) {
|
|
64558
64600
|
return res.status(400).json({ message: error.message });
|
|
64559
64601
|
}
|
|
64602
|
+
if (await refuseUnreachableSite(req, res, siteId))
|
|
64603
|
+
return;
|
|
64560
64604
|
const result = await getCardDetailsSvc({ siteId, cardId });
|
|
64561
64605
|
return res.status(200).json({ message: "Success", data: result });
|
|
64562
64606
|
} catch (error) {
|
|
@@ -64585,6 +64629,8 @@ function useAccessManagementController() {
|
|
|
64585
64629
|
if (error) {
|
|
64586
64630
|
return res.status(400).json({ message: error.message });
|
|
64587
64631
|
}
|
|
64632
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64633
|
+
return;
|
|
64588
64634
|
const result = await addQrTagSvc({ payload, site });
|
|
64589
64635
|
return res.status(200).json({ message: "Success", data: result });
|
|
64590
64636
|
} catch (error) {
|
|
@@ -64604,6 +64650,8 @@ function useAccessManagementController() {
|
|
|
64604
64650
|
if (error) {
|
|
64605
64651
|
return res.status(400).json({ message: error.message });
|
|
64606
64652
|
}
|
|
64653
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64654
|
+
return;
|
|
64607
64655
|
const result = await allQrTagSvc({ site });
|
|
64608
64656
|
return res.status(200).json({ message: "Success", data: result });
|
|
64609
64657
|
} catch (error) {
|
|
@@ -64633,6 +64681,8 @@ function useAccessManagementController() {
|
|
|
64633
64681
|
if (error) {
|
|
64634
64682
|
return res.status(400).json({ message: error.message });
|
|
64635
64683
|
}
|
|
64684
|
+
if (await refuseUnreachableSite(req, res, siteId))
|
|
64685
|
+
return;
|
|
64636
64686
|
const result = await availableCardContractorsSvc({
|
|
64637
64687
|
siteId,
|
|
64638
64688
|
unitId,
|
|
@@ -64665,6 +64715,8 @@ function useAccessManagementController() {
|
|
|
64665
64715
|
return res.status(400).json({ message: error.message });
|
|
64666
64716
|
}
|
|
64667
64717
|
const normalizedUnitId = [unitId];
|
|
64718
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64719
|
+
return;
|
|
64668
64720
|
const result = await vmsgenerateQrCodesSvc({
|
|
64669
64721
|
site,
|
|
64670
64722
|
unitId,
|
|
@@ -64716,6 +64768,8 @@ function useAccessManagementController() {
|
|
|
64716
64768
|
if (error) {
|
|
64717
64769
|
return res.status(400).json({ message: error.message });
|
|
64718
64770
|
}
|
|
64771
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64772
|
+
return;
|
|
64719
64773
|
const result = await addVisitorAccessCardSvc({
|
|
64720
64774
|
site,
|
|
64721
64775
|
unitId,
|
|
@@ -64792,6 +64846,8 @@ function useAccessManagementController() {
|
|
|
64792
64846
|
if (!site || typeof site !== "string") {
|
|
64793
64847
|
throw new Error("Site is required");
|
|
64794
64848
|
}
|
|
64849
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64850
|
+
return;
|
|
64795
64851
|
const result = await getBlockLevelAndUnitListSvc({ site });
|
|
64796
64852
|
return res.status(200).json({ message: "Success", data: result });
|
|
64797
64853
|
} catch (error) {
|
|
@@ -64887,6 +64943,8 @@ function useAccessManagementController() {
|
|
|
64887
64943
|
if (error) {
|
|
64888
64944
|
return res.status(400).json({ message: error.message });
|
|
64889
64945
|
}
|
|
64946
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
64947
|
+
return;
|
|
64890
64948
|
const result = await uploadTemplateSvc({ site, id, name });
|
|
64891
64949
|
return res.status(200).json({ message: "Success", data: result });
|
|
64892
64950
|
} catch (error) {
|
|
@@ -64908,6 +64966,8 @@ function useAccessManagementController() {
|
|
|
64908
64966
|
if (error) {
|
|
64909
64967
|
return res.status(400).json({ message: error.message });
|
|
64910
64968
|
}
|
|
64969
|
+
if (await refuseUnreachableSite(req, res, siteId))
|
|
64970
|
+
return;
|
|
64911
64971
|
const result = await getResidentsSvc({ orgId, siteId, unitId });
|
|
64912
64972
|
return res.status(200).json({ data: result });
|
|
64913
64973
|
} catch (error) {
|
|
@@ -64931,6 +64991,8 @@ function useAccessManagementController() {
|
|
|
64931
64991
|
return res.status(400).json({ message: error.message });
|
|
64932
64992
|
}
|
|
64933
64993
|
const isLiftCardBool = isLiftCard === "true";
|
|
64994
|
+
if (await refuseUnreachableSite(req, res, siteId))
|
|
64995
|
+
return;
|
|
64934
64996
|
const result = await userAccessCardsSvc({
|
|
64935
64997
|
userId,
|
|
64936
64998
|
siteId,
|
|
@@ -64955,6 +65017,8 @@ function useAccessManagementController() {
|
|
|
64955
65017
|
if (error) {
|
|
64956
65018
|
return res.status(400).json({ message: error.message });
|
|
64957
65019
|
}
|
|
65020
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
65021
|
+
return;
|
|
64958
65022
|
const result = await removeTemplateSvc({ site });
|
|
64959
65023
|
return res.status(200).json({ data: result });
|
|
64960
65024
|
} catch (error) {
|
|
@@ -64988,6 +65052,8 @@ function useAccessManagementController() {
|
|
|
64988
65052
|
if (error) {
|
|
64989
65053
|
return res.status(400).json({ message: error.message });
|
|
64990
65054
|
}
|
|
65055
|
+
if (await refuseUnreachableSite(req, res, site))
|
|
65056
|
+
return;
|
|
64991
65057
|
const result = await qrCodeListSvc({
|
|
64992
65058
|
type,
|
|
64993
65059
|
site,
|