@7365admin1/layer-common 4.2.26 → 4.2.28
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
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.2.28
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 182a86e: Make the app root await the role resolve again
|
|
8
|
+
|
|
9
|
+
4.2.24 carved `to.name === "index"` out of the `await` in the `secure-member`
|
|
10
|
+
route guard: the app root started the member/role lookup and returned without
|
|
11
|
+
it, so the first screen painted with `userAppRole` still null.
|
|
12
|
+
|
|
13
|
+
Every permission gate in this package fails closed on a null role -
|
|
14
|
+
`DashboardMain.vue`'s `canViewWidget` returns `false` the moment `permissions`
|
|
15
|
+
is undefined - so a signed-in user could reach a first paint with no widgets
|
|
16
|
+
and no module navigation. The saving was two round trips on one screen; the
|
|
17
|
+
cost was a gate evaluated against an unresolved role.
|
|
18
|
+
|
|
19
|
+
The guard awaits on every route again, root included, exactly as it did in
|
|
20
|
+
4.2.23. `useLocalAuth` goes back with it: its shared-request and
|
|
21
|
+
fire-and-forget `authenticate()` changes shipped in the same change and are
|
|
22
|
+
only meaningful alongside it.
|
|
23
|
+
|
|
24
|
+
Three tests pin it: the root guard is held open while the lookup is deferred
|
|
25
|
+
and observed not to return; the permissions a gate reads are asserted non-null
|
|
26
|
+
the instant the guard returns; and the shipped source is checked for any
|
|
27
|
+
route-name exception to the await.
|
|
28
|
+
|
|
29
|
+
The ANPR plate toast (4.2.25), the notification-settings channel summary
|
|
30
|
+
(4.2.26) and the Invite Client role picker (4.2.27) are unchanged.
|
|
31
|
+
|
|
32
|
+
## 4.2.27
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- 21cddf9: Invite Client: stop offering Seven365 console staff roles on a client invitation.
|
|
37
|
+
|
|
38
|
+
The console's Invite Client picker lists the org-less roles, which includes the platform's own `type: "admin"` staff roles. The App field on that form only offers the seven service types, so the server (`core invite-role-scope.util roleInvitable`) refuses a staff role on every invitation the form can send — two of the twelve options could only ever be picked and then fail. They are now hidden. Display only: the request is unchanged and every role the server accepts is still offered.
|
|
39
|
+
|
|
3
40
|
## 4.2.26
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -793,11 +830,11 @@
|
|
|
793
830
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
794
831
|
own rule from two endpoints the console already calls, unprojected:
|
|
795
832
|
|
|
796
|
-
|
|
797
|
-
|
|
833
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
834
|
+
GET /api/roles/id/:role that membership's role document
|
|
798
835
|
|
|
799
|
-
|
|
800
|
-
|
|
836
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
837
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
801
838
|
|
|
802
839
|
`role.default` is the marker because it is the only property of a platform
|
|
803
840
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -258,7 +258,21 @@ const { data: roleData, refresh: refreshRoles } = await useLazyAsyncData(
|
|
|
258
258
|
)
|
|
259
259
|
|
|
260
260
|
watchEffect(() => {
|
|
261
|
-
|
|
261
|
+
/*
|
|
262
|
+
* The App field above offers the seven service types and never the Seven365
|
|
263
|
+
* staff type (`APP_LIST`), so every invitation this screen can send is a
|
|
264
|
+
* non-staff one -- and `core invite-role-scope.util roleInvitable` refuses a
|
|
265
|
+
* `type: "admin"` role on any of those, without exception. The request that
|
|
266
|
+
* fills this list goes out as `org: "", type: ""`, which is the ORG-LESS set:
|
|
267
|
+
* on staging that is 12 roles, 2 of them `type: "admin"`. So 2 of the 12
|
|
268
|
+
* options could only ever be picked and then refused.
|
|
269
|
+
*
|
|
270
|
+
* Display only. The server's decision is unchanged, and nothing this form can
|
|
271
|
+
* successfully send is removed -- the 10 `type: "organization"` templates,
|
|
272
|
+
* including "Org Owner" (117 live members, 321 invitations), all stay.
|
|
273
|
+
*/
|
|
274
|
+
if (roleData.value)
|
|
275
|
+
roles.value = roleData.value.items.filter((r: any) => r?.type !== 'admin')
|
|
262
276
|
})
|
|
263
277
|
|
|
264
278
|
watch(
|
|
@@ -1,36 +1,25 @@
|
|
|
1
|
-
// One in-flight `GET /api/users/id/:id` per page load, shared by every caller.
|
|
2
|
-
// These apps are `ssr: false`, so module scope is exactly one browser session.
|
|
3
|
-
// The route guard starts this request in parallel with the member lookup and
|
|
4
|
-
// the first screen asks for it again on setup; without this that is two
|
|
5
|
-
// identical requests instead of one.
|
|
6
|
-
let currentUserRequest: Promise<any> | null = null;
|
|
7
|
-
|
|
8
1
|
export default function useLocalAuth() {
|
|
9
2
|
const { cookieConfig } = useRuntimeConfig().public;
|
|
10
3
|
|
|
11
4
|
const currentUser = useState<TUser | null>("currentUser", () => null);
|
|
12
5
|
|
|
13
|
-
// Goes through the same request `getCurrentUser` makes, so it joins the one
|
|
14
|
-
// the route guard already started instead of issuing a second.
|
|
15
|
-
//
|
|
16
|
-
// DELIBERATELY NOT AWAITED INSIDE. 19 pages call this with a top-level
|
|
17
|
-
// `await`, and the `useLazyAsyncData` it replaces returned before its request
|
|
18
|
-
// did; awaiting the request here would newly suspend every one of them.
|
|
19
6
|
async function authenticate() {
|
|
20
7
|
const user = useCookie("user", cookieConfig).value;
|
|
21
8
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
navigateTo({ name: "index" });
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
9
|
+
const { data: getCurrentUserReq, error: getCurrentUserErr } =
|
|
10
|
+
await useLazyAsyncData("getCurrentUser", () =>
|
|
11
|
+
useNuxtApp().$api<TUser>(`/api/users/id/${user}`)
|
|
12
|
+
);
|
|
29
13
|
|
|
30
|
-
|
|
31
|
-
currentUser.value = null;
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
watchEffect(() => {
|
|
15
|
+
currentUser.value = (getCurrentUserReq.value as TUser | null) ?? null;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
watchEffect(() => {
|
|
19
|
+
if (getCurrentUserErr.value) {
|
|
20
|
+
// Redirect to login page if user authentication fails
|
|
21
|
+
navigateTo({ name: "index" });
|
|
22
|
+
}
|
|
34
23
|
});
|
|
35
24
|
}
|
|
36
25
|
|
|
@@ -74,16 +63,9 @@ export default function useLocalAuth() {
|
|
|
74
63
|
currentUser.value = null;
|
|
75
64
|
return null;
|
|
76
65
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.finally(() => {
|
|
81
|
-
// Cleared on success AND on failure: this collapses callers that
|
|
82
|
-
// overlap, it does not cache the answer.
|
|
83
|
-
currentUserRequest = null;
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
const _user = (await currentUserRequest) as TUser;
|
|
66
|
+
const _user = await useNuxtApp().$api<TUser>(`/api/users/id/${user}`, {
|
|
67
|
+
method: "GET",
|
|
68
|
+
});
|
|
87
69
|
currentUser.value = _user;
|
|
88
70
|
return _user;
|
|
89
71
|
}
|
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.2.
|
|
5
|
+
"version": "4.2.28",
|
|
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.",
|
|
@@ -13,7 +13,6 @@ export default defineNuxtPlugin(() => {
|
|
|
13
13
|
const { getByUserType } = useMember();
|
|
14
14
|
const { getRoleById } = useRole();
|
|
15
15
|
const { getById } = useOrg();
|
|
16
|
-
const { getCurrentUser } = useLocalAuth();
|
|
17
16
|
|
|
18
17
|
const { userAppRole, userAppRoleStatus, id, orgNature } = useLocalSetup();
|
|
19
18
|
|
|
@@ -22,7 +21,6 @@ export default defineNuxtPlugin(() => {
|
|
|
22
21
|
let resolvedFor: string | null = null;
|
|
23
22
|
let inFlight: Promise<void> | null = null;
|
|
24
23
|
let hasMemberDocument = false;
|
|
25
|
-
let primedUser = false;
|
|
26
24
|
|
|
27
25
|
// Deliberately never redirects and never throws.
|
|
28
26
|
//
|
|
@@ -70,40 +68,13 @@ export default defineNuxtPlugin(() => {
|
|
|
70
68
|
router.beforeEach(async (to) => {
|
|
71
69
|
const userId = useCookie("user").value ?? "";
|
|
72
70
|
|
|
73
|
-
// The signed-in user's own record is a THIRD round trip and almost every
|
|
74
|
-
// first screen wants it, but page setup only runs once the guard below has
|
|
75
|
-
// returned -- so it used to start after both lookups had finished. Started
|
|
76
|
-
// here it runs alongside them. `getCurrentUser` collapses concurrent
|
|
77
|
-
// callers onto one request, so the page asking for it again costs nothing.
|
|
78
|
-
if (userId && !primedUser) {
|
|
79
|
-
primedUser = true;
|
|
80
|
-
void getCurrentUser().catch(() => {
|
|
81
|
-
// A failed prime is not this guard's business: every caller that needs
|
|
82
|
-
// the user asks again and handles its own failure.
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
71
|
// Resolve for EVERY authenticated route, not only `memberOnly` ones. Gates
|
|
87
72
|
// are read on pages that carry no such flag -- the staff console cannot
|
|
88
73
|
// carry it at all, it has no organisation in the route -- and until this
|
|
89
74
|
// ran there the role stayed null for the life of the page: gates that
|
|
90
75
|
// default open granted everything, gates that fail closed denied everything.
|
|
91
76
|
// Awaited, so no gate is ever evaluated against an unresolved role.
|
|
92
|
-
|
|
93
|
-
// The ONE exception is the app root. It renders no permission-gated
|
|
94
|
-
// surface -- it reads the signed-in email, and leaves -- so waiting two
|
|
95
|
-
// serial round trips there delays the first paint of every app by the
|
|
96
|
-
// length of both and buys nothing. Started, not awaited. Every other
|
|
97
|
-
// route, root-or-not, still awaits, and a route reached while this is
|
|
98
|
-
// still in flight awaits THIS promise: `resolveAppRole` returns the
|
|
99
|
-
// in-flight one rather than starting a second.
|
|
100
|
-
if (userId) {
|
|
101
|
-
if (to.name === "index" && !to.meta?.memberOnly) {
|
|
102
|
-
void resolveAppRole(userId);
|
|
103
|
-
} else {
|
|
104
|
-
await resolveAppRole(userId);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
77
|
+
if (userId) await resolveAppRole(userId);
|
|
107
78
|
|
|
108
79
|
const isMember = to.meta?.memberOnly;
|
|
109
80
|
|