@7365admin1/layer-common 4.189.1 → 4.189.2
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 +10 -4
- package/components/Layout/Header.vue +45 -1
- package/package.json +1 -1
- package/utils/account-return.ts +58 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.189.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- aa58650: Manage Account passes the current page, and the header shares it (only iService365 addresses) as the `account-return` state, so the Account app can show a Back button to it.
|
|
8
|
+
|
|
3
9
|
## 4.189.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -4148,11 +4154,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
|
|
|
4148
4154
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
4149
4155
|
own rule from two endpoints the console already calls, unprojected:
|
|
4150
4156
|
|
|
4151
|
-
|
|
4152
|
-
|
|
4157
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
4158
|
+
GET /api/roles/id/:role that membership's role document
|
|
4153
4159
|
|
|
4154
|
-
|
|
4155
|
-
|
|
4160
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
4161
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
4156
4162
|
|
|
4157
4163
|
`role.default` is the marker because it is the only property of a platform
|
|
4158
4164
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
v-if="APP_NAME.toLowerCase() !== 'account'"
|
|
75
75
|
type="button"
|
|
76
76
|
class="app-profile-menu__row"
|
|
77
|
-
@click="
|
|
77
|
+
@click="openAccount()"
|
|
78
78
|
>
|
|
79
79
|
<v-icon icon="mdi-account-cog-outline" size="18" />
|
|
80
80
|
Manage Account
|
|
@@ -131,6 +131,11 @@
|
|
|
131
131
|
// Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
|
|
132
132
|
import { uiTr } from "../../composables/useUiLanguage";
|
|
133
133
|
import { moduleNameFromRoute } from "../../utils/breadcrumb";
|
|
134
|
+
import {
|
|
135
|
+
ACCOUNT_RETURN_KEY,
|
|
136
|
+
ACCOUNT_RETURN_STATE,
|
|
137
|
+
safeAccountReturn,
|
|
138
|
+
} from "../../utils/account-return";
|
|
134
139
|
|
|
135
140
|
const props = defineProps({
|
|
136
141
|
hideNavIcon: {
|
|
@@ -246,6 +251,45 @@ const profile = computed(() => {
|
|
|
246
251
|
return `/api/public/${currentUser.value?.profile}`;
|
|
247
252
|
});
|
|
248
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Manage Account carries the page the user is on, so the Account application
|
|
256
|
+
* can offer a way back to it (DV-1874). It opens Personal Info directly:
|
|
257
|
+
* `/home` is a server redirect there that would drop the query.
|
|
258
|
+
*/
|
|
259
|
+
function openAccount() {
|
|
260
|
+
redirect(
|
|
261
|
+
APP_ACCOUNT,
|
|
262
|
+
`personal-info?return=${encodeURIComponent(window.location.href)}`
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* In the Account application, the Back target: taken from `?return=` when it
|
|
268
|
+
* arrives (and only if it is one of our own apps), then kept for the tab's
|
|
269
|
+
* session so it survives moving between the Personal Info screens, which drop
|
|
270
|
+
* the query. Read in `onMounted` - the bar is pre-rendered on the server,
|
|
271
|
+
* where there is no `window` or `sessionStorage`.
|
|
272
|
+
*
|
|
273
|
+
* The bar only WORKS IT OUT; the Account app's Personal Info page draws the
|
|
274
|
+
* Back button above its "Profile Info" title (owner's placement, DV-1874),
|
|
275
|
+
* reading this shared state.
|
|
276
|
+
*/
|
|
277
|
+
const accountReturn = useState<string>(ACCOUNT_RETURN_STATE, () => "");
|
|
278
|
+
|
|
279
|
+
onMounted(() => {
|
|
280
|
+
if (APP_NAME.toLowerCase() !== "account") return;
|
|
281
|
+
try {
|
|
282
|
+
const fromQuery = safeAccountReturn(route.query.return, String(APP_ACCOUNT));
|
|
283
|
+
if (fromQuery) sessionStorage.setItem(ACCOUNT_RETURN_KEY, fromQuery);
|
|
284
|
+
accountReturn.value =
|
|
285
|
+
fromQuery ||
|
|
286
|
+
safeAccountReturn(sessionStorage.getItem(ACCOUNT_RETURN_KEY), String(APP_ACCOUNT));
|
|
287
|
+
} catch {
|
|
288
|
+
// Storage blocked (private mode): fall back to the query alone.
|
|
289
|
+
accountReturn.value = safeAccountReturn(route.query.return, String(APP_ACCOUNT));
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
249
293
|
function logout() {
|
|
250
294
|
if (APP_NAME.toLowerCase() !== "main") {
|
|
251
295
|
redirect(APP_MAIN, "logout");
|
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.189.
|
|
5
|
+
"version": "4.189.2",
|
|
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.",
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE ACCOUNT SITE'S "BACK" LINK (DV-1874).
|
|
3
|
+
*
|
|
4
|
+
* Manage Account sends the user to the Account application on its own
|
|
5
|
+
* hostname, and that application had no way back: no button, no link, only the
|
|
6
|
+
* browser's Back. The services apps now pass the page the user was on as
|
|
7
|
+
* `?return=`, and the Account header offers a Back button to it.
|
|
8
|
+
*
|
|
9
|
+
* `?return=` comes from the address bar, so it is untrusted: a link that sends
|
|
10
|
+
* someone to Account with `?return=https://evil.example` must not turn our
|
|
11
|
+
* Back button into an open redirect. Only an http(s) address on the SAME parent
|
|
12
|
+
* domain as the Account application itself is accepted:
|
|
13
|
+
*
|
|
14
|
+
* account.app.iservice365.org -> *.app.iservice365.org
|
|
15
|
+
* iservice365-staging-account.apptesting.work -> *.apptesting.work
|
|
16
|
+
* localhost (development) -> localhost
|
|
17
|
+
*
|
|
18
|
+
* The Account application itself is refused - "Back" to the page you are on is
|
|
19
|
+
* no way back at all.
|
|
20
|
+
*/
|
|
21
|
+
export function safeAccountReturn(candidate: unknown, accountUrl: string): string {
|
|
22
|
+
if (typeof candidate !== "string" || !candidate) return "";
|
|
23
|
+
|
|
24
|
+
let target: URL;
|
|
25
|
+
let account: URL;
|
|
26
|
+
try {
|
|
27
|
+
target = new URL(candidate);
|
|
28
|
+
account = new URL(accountUrl);
|
|
29
|
+
} catch {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (target.protocol !== "https:" && target.protocol !== "http:") return "";
|
|
34
|
+
if (target.origin === account.origin) return "";
|
|
35
|
+
|
|
36
|
+
const host = target.hostname.toLowerCase();
|
|
37
|
+
const accountHost = account.hostname.toLowerCase();
|
|
38
|
+
|
|
39
|
+
if (accountHost === "localhost" || accountHost === "127.0.0.1") {
|
|
40
|
+
return host === accountHost ? target.href : "";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// The Account host minus its first label is the shared parent domain.
|
|
44
|
+
const parent = accountHost.split(".").slice(1).join(".");
|
|
45
|
+
if (!parent || !parent.includes(".")) return "";
|
|
46
|
+
|
|
47
|
+
return host.endsWith(`.${parent}`) ? target.href : "";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Where the Account header keeps the Back target while the user moves around it. */
|
|
51
|
+
export const ACCOUNT_RETURN_KEY = "account-return-to";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The `useState` key the header fills with the checked Back target, for the
|
|
55
|
+
* Account app's Personal Info page to draw its Back button from. Empty when
|
|
56
|
+
* there is nowhere safe to go back to.
|
|
57
|
+
*/
|
|
58
|
+
export const ACCOUNT_RETURN_STATE = "account-return";
|