@7365admin1/layer-common 4.97.1-staging.537 → 4.97.1-staging.539
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.
|
@@ -6,17 +6,43 @@
|
|
|
6
6
|
>
|
|
7
7
|
<v-row no-gutters>
|
|
8
8
|
<v-col cols="12">
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
<!-- Which QR code types a resident's visitor invitation can carry. -->
|
|
10
|
+
<template v-for="option in visitorQrCodes" :key="option.type">
|
|
11
|
+
<div class="d-flex align-center justify-space-between py-3">
|
|
12
|
+
<div>
|
|
13
|
+
<div class="text-body-2 font-weight-medium">{{ visitorQrLabels[option.type].title }}</div>
|
|
14
|
+
<p class="text-caption text-medium-emphasis mt-1 mb-0">
|
|
15
|
+
{{ visitorQrLabels[option.type].description }}
|
|
16
|
+
</p>
|
|
17
|
+
</div>
|
|
12
18
|
<v-switch
|
|
13
|
-
v-model="
|
|
14
|
-
hide-details
|
|
19
|
+
v-model="option.isEnabled"
|
|
15
20
|
color="success"
|
|
16
|
-
|
|
21
|
+
inset
|
|
22
|
+
density="compact"
|
|
23
|
+
hide-details
|
|
24
|
+
class="flex-grow-0 ml-4"
|
|
17
25
|
/>
|
|
18
|
-
</
|
|
19
|
-
|
|
26
|
+
</div>
|
|
27
|
+
<v-divider />
|
|
28
|
+
</template>
|
|
29
|
+
<div class="d-flex align-center justify-space-between py-3">
|
|
30
|
+
<div>
|
|
31
|
+
<div class="text-body-2 font-weight-medium">Allow Opening Barrier via Plate Number?</div>
|
|
32
|
+
<p class="text-caption text-medium-emphasis mt-1 mb-0">
|
|
33
|
+
When enabled, the barrier can be opened for visitors by matching their vehicle plate number.
|
|
34
|
+
</p>
|
|
35
|
+
</div>
|
|
36
|
+
<v-switch
|
|
37
|
+
v-model="isAllowPlateNumberOpenBarrier"
|
|
38
|
+
color="success"
|
|
39
|
+
inset
|
|
40
|
+
density="compact"
|
|
41
|
+
hide-details
|
|
42
|
+
class="flex-grow-0 ml-4"
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
<v-divider class="mb-4" />
|
|
20
46
|
<v-row
|
|
21
47
|
no-gutters
|
|
22
48
|
class="d-flex align-center ga-2 justify-space-between"
|
|
@@ -220,6 +246,26 @@ const isAllowPlateNumberOpenBarrier = ref(false);
|
|
|
220
246
|
const autoApproveOvernightParking = ref(false);
|
|
221
247
|
const isHydrating = ref(true);
|
|
222
248
|
|
|
249
|
+
const visitorQrLabels: Record<TVisitorQrCodeType, { title: string; description: string }> = {
|
|
250
|
+
hid: {
|
|
251
|
+
title: "HID QR Code Visitor Invitation",
|
|
252
|
+
description: "When enabled, HID QR codes will be generated for visitor invitations instead of standard entry pass QR codes.",
|
|
253
|
+
},
|
|
254
|
+
entryPass: {
|
|
255
|
+
title: "Entry Pass QR Code Visitor Invitation",
|
|
256
|
+
description: "When enabled, entry pass QR codes will be generated for visitor invitations.",
|
|
257
|
+
},
|
|
258
|
+
security: {
|
|
259
|
+
title: "Security QR Code Visitor Invitation",
|
|
260
|
+
description: "When enabled, security QR codes will be generated for visitor invitations.",
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
const visitorQrCodes = ref<TVisitorQrCode[]>([
|
|
264
|
+
{ type: "hid", isEnabled: false },
|
|
265
|
+
{ type: "security", isEnabled: false },
|
|
266
|
+
{ type: "entryPass", isEnabled: false },
|
|
267
|
+
]);
|
|
268
|
+
|
|
223
269
|
const { requiredRule } = useUtils();
|
|
224
270
|
const { generateTimeSlots, generateTimeSlotsFromStart } = useFacilityUtils();
|
|
225
271
|
const { currentUser } = useLocalAuth();
|
|
@@ -290,6 +336,13 @@ watch(
|
|
|
290
336
|
autoApproveOvernightParking.value =
|
|
291
337
|
data?.autoApproveOvernightParking === true ||
|
|
292
338
|
data?.isAutoApproved === true;
|
|
339
|
+
// Set in place so the toggle watcher only fires on a real change.
|
|
340
|
+
visitorQrCodes.value.forEach((option) => {
|
|
341
|
+
const saved = (data?.visitorQrCodes as TVisitorQrCode[] | undefined)?.find(
|
|
342
|
+
(q) => q.type === option.type
|
|
343
|
+
);
|
|
344
|
+
option.isEnabled = saved?.isEnabled === true;
|
|
345
|
+
});
|
|
293
346
|
setTimeout(() => {
|
|
294
347
|
isHydrating.value = false;
|
|
295
348
|
}, 500);
|
|
@@ -374,7 +427,7 @@ watch(
|
|
|
374
427
|
isAllowPlateNumberOpenBarrier,
|
|
375
428
|
(newValue, oldValue) => {
|
|
376
429
|
if (oldValue === newValue || isHydrating.value) return;
|
|
377
|
-
handleSave("toggle");
|
|
430
|
+
handleSave("toggle", "Plate number barrier setting updated successfully.");
|
|
378
431
|
},
|
|
379
432
|
{ immediate: false }
|
|
380
433
|
);
|
|
@@ -388,7 +441,19 @@ watch(
|
|
|
388
441
|
{ immediate: false }
|
|
389
442
|
);
|
|
390
443
|
|
|
391
|
-
|
|
444
|
+
watch(
|
|
445
|
+
visitorQrCodes,
|
|
446
|
+
() => {
|
|
447
|
+
if (isHydrating.value) return;
|
|
448
|
+
handleSave("toggle", "Visitor QR settings updated successfully.");
|
|
449
|
+
},
|
|
450
|
+
{ deep: true }
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
async function handleSave(
|
|
454
|
+
action: "toggle" | "save",
|
|
455
|
+
successMessage = "Overnight parking settings updated successfully."
|
|
456
|
+
) {
|
|
392
457
|
if (!isValid.value && action === "save") {
|
|
393
458
|
message.value = "Please fill in all required fields.";
|
|
394
459
|
messageColor.value = "error";
|
|
@@ -403,6 +468,7 @@ async function handleSave(action: "toggle" | "save") {
|
|
|
403
468
|
isAllowPlateNumberOpenBarrier: isAllowPlateNumberOpenBarrier.value,
|
|
404
469
|
autoApproveOvernightParking: autoApproveOvernightParking.value,
|
|
405
470
|
isAutoApproved: autoApproveOvernightParking.value,
|
|
471
|
+
visitorQrCodes: visitorQrCodes.value.map(({ type, isEnabled }) => ({ type, isEnabled })),
|
|
406
472
|
updatedBy: updatedByValue.value,
|
|
407
473
|
};
|
|
408
474
|
|
|
@@ -414,7 +480,7 @@ async function handleSave(action: "toggle" | "save") {
|
|
|
414
480
|
userType.value
|
|
415
481
|
);
|
|
416
482
|
refreshAvailability();
|
|
417
|
-
message.value =
|
|
483
|
+
message.value = successMessage;
|
|
418
484
|
messageColor.value = "success";
|
|
419
485
|
messageSnackbar.value = true;
|
|
420
486
|
} catch (error) {
|
package/middleware/01.auth.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { termsGateSkips } from "../utils/terms-gate";
|
|
2
|
-
|
|
3
1
|
export default defineNuxtRouteMiddleware(async (route) => {
|
|
4
2
|
const { cookieConfig } = useRuntimeConfig().public;
|
|
5
3
|
|
|
@@ -14,13 +12,5 @@ export default defineNuxtRouteMiddleware(async (route) => {
|
|
|
14
12
|
// Redirect to login page if no access token
|
|
15
13
|
return navigateTo({ name: "index" });
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
// Terms and Privacy Policy: ask once per account per published version.
|
|
19
|
-
// Fails open; print/PDF/preview/kiosk/public (plain layout) pages are skipped.
|
|
20
|
-
if (import.meta.client && !termsGateSkips(route, navigator.userAgent)) {
|
|
21
|
-
const { check } = useTermsGate();
|
|
22
|
-
if (await check()) {
|
|
23
|
-
return navigateTo({ path: "/accept-terms", query: { redirect: route.fullPath } });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
15
|
+
// Terms and Privacy gate: see terms-gate.global.ts (runs on every page).
|
|
26
16
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { termsGateRedirect } from "../utils/terms-gate";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* "Accept Terms and Privacy Policy" gate for EVERY page in every app that
|
|
5
|
+
* extends layer-common. It was in the named `01-auth` middleware, so pages that
|
|
6
|
+
* did not declare it were never gated. Client-only, only with a `sid`, fails
|
|
7
|
+
* open, and reuses useTermsGate's cached answer (no extra call per navigation).
|
|
8
|
+
*/
|
|
9
|
+
export default defineNuxtRouteMiddleware(async (to) => {
|
|
10
|
+
const { cookieConfig } = useRuntimeConfig().public;
|
|
11
|
+
const redirect = await termsGateRedirect({
|
|
12
|
+
client: import.meta.client,
|
|
13
|
+
sid: useCookie("sid", cookieConfig).value,
|
|
14
|
+
to,
|
|
15
|
+
userAgent: import.meta.client ? navigator.userAgent : "",
|
|
16
|
+
check: () => useTermsGate().check(),
|
|
17
|
+
});
|
|
18
|
+
if (redirect) return navigateTo(redirect);
|
|
19
|
+
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.539",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
|
@@ -14,6 +14,14 @@ declare type TOvernightParkingAvailability = {
|
|
|
14
14
|
sunday: TOvernightParkingDay;
|
|
15
15
|
isAllowPlateNumberOpenBarrier?: boolean;
|
|
16
16
|
autoApproveOvernightParking?: boolean;
|
|
17
|
+
visitorQrCodes?: TVisitorQrCode[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare type TVisitorQrCodeType = "hid" | "entryPass" | "security";
|
|
21
|
+
|
|
22
|
+
declare type TVisitorQrCode = {
|
|
23
|
+
type: TVisitorQrCodeType;
|
|
24
|
+
isEnabled: boolean;
|
|
17
25
|
};
|
|
18
26
|
|
|
19
27
|
declare type TOvernightParkingRequestStatus =
|
package/utils/terms-gate.ts
CHANGED
|
@@ -19,6 +19,17 @@ export function shouldPrompt(reply: TermsGateReply | null | undefined): boolean
|
|
|
19
19
|
|
|
20
20
|
const NEVER_GATED_LAYOUTS = ["plain", "plain-dark"];
|
|
21
21
|
|
|
22
|
+
// Pre-login and public pages. Most are also `plain` layout; listed by path as a
|
|
23
|
+
// second net so a public page can never loop through the gate.
|
|
24
|
+
const PUBLIC_PATHS = [
|
|
25
|
+
"/sign-in", "/sign-up", "/sign-up-invite", "/forgot-password", "/reset-password",
|
|
26
|
+
"/verify", "/logout", "/public-view", "/terms-and-conditions", "/privacy-policy",
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
function isPublicPath(path = ""): boolean {
|
|
30
|
+
return PUBLIC_PATHS.some((p) => path === p || path.startsWith(p + "/"));
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
/**
|
|
23
34
|
* Pages that must never be interrupted: print/PDF/preview/kiosk/public pages
|
|
24
35
|
* (they use the plain layouts), the accept page itself, an explicit opt-out,
|
|
@@ -29,6 +40,7 @@ export function termsGateSkips(
|
|
|
29
40
|
userAgent = "",
|
|
30
41
|
): boolean {
|
|
31
42
|
if (to.path === "/accept-terms") return true;
|
|
43
|
+
if (isPublicPath(to.path)) return true;
|
|
32
44
|
const meta = to.meta ?? {};
|
|
33
45
|
if (meta.skipTermsGate) return true;
|
|
34
46
|
if (typeof meta.layout === "string" && NEVER_GATED_LAYOUTS.includes(meta.layout)) return true;
|
|
@@ -43,3 +55,25 @@ export function safeRedirect(value: unknown): string {
|
|
|
43
55
|
}
|
|
44
56
|
return path;
|
|
45
57
|
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The global gate's decision: the path to redirect to, or null to let the page
|
|
61
|
+
* through. `check` (useTermsGate().check) already fails open and is cached, so
|
|
62
|
+
* this adds no API call per navigation.
|
|
63
|
+
*/
|
|
64
|
+
export async function termsGateRedirect(opts: {
|
|
65
|
+
client: boolean;
|
|
66
|
+
sid: unknown;
|
|
67
|
+
to: { path?: string; fullPath?: string; meta?: Record<string, unknown> };
|
|
68
|
+
userAgent?: string;
|
|
69
|
+
check: () => Promise<boolean>;
|
|
70
|
+
}): Promise<{ path: string; query: { redirect: string } } | null> {
|
|
71
|
+
if (!opts.client || !opts.sid || termsGateSkips(opts.to, opts.userAgent)) return null;
|
|
72
|
+
let must = false;
|
|
73
|
+
try {
|
|
74
|
+
must = await opts.check();
|
|
75
|
+
} catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return must ? { path: "/accept-terms", query: { redirect: opts.to.fullPath ?? opts.to.path ?? "/" } } : null;
|
|
79
|
+
}
|