@7365admin1/layer-common 4.97.1-staging.735 → 4.97.1-staging.736
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/components/Layout/Header.vue +50 -1
- package/package.json +1 -1
- package/utils/account-return.ts +51 -0
|
@@ -21,6 +21,19 @@
|
|
|
21
21
|
>
|
|
22
22
|
<v-app-bar-nav-icon v-if="!props.hideNavIcon" @click="drawer = !drawer"></v-app-bar-nav-icon>
|
|
23
23
|
|
|
24
|
+
<!-- Account application only: back to the services app page that opened
|
|
25
|
+
Manage Account (DV-1874). Shown only when that page was passed in and
|
|
26
|
+
is one of ours - see `utils/account-return.ts`. -->
|
|
27
|
+
<v-btn
|
|
28
|
+
v-if="accountReturn"
|
|
29
|
+
:href="accountReturn"
|
|
30
|
+
variant="text"
|
|
31
|
+
prepend-icon="mdi-arrow-left"
|
|
32
|
+
class="text-none me-2"
|
|
33
|
+
>
|
|
34
|
+
Back
|
|
35
|
+
</v-btn>
|
|
36
|
+
|
|
24
37
|
<div ref="crumbEl" class="app-topbar-shell__crumb">
|
|
25
38
|
<span v-if="siteName" class="app-topbar-shell__site">{{ siteName }}</span>
|
|
26
39
|
<span v-if="siteName && moduleName" class="app-topbar-shell__sep">/</span>
|
|
@@ -74,7 +87,7 @@
|
|
|
74
87
|
v-if="APP_NAME.toLowerCase() !== 'account'"
|
|
75
88
|
type="button"
|
|
76
89
|
class="app-profile-menu__row"
|
|
77
|
-
@click="
|
|
90
|
+
@click="openAccount()"
|
|
78
91
|
>
|
|
79
92
|
<v-icon icon="mdi-account-cog-outline" size="18" />
|
|
80
93
|
Manage Account
|
|
@@ -131,6 +144,7 @@
|
|
|
131
144
|
// Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
|
|
132
145
|
import { uiTr } from "../../composables/useUiLanguage";
|
|
133
146
|
import { moduleNameFromRoute } from "../../utils/breadcrumb";
|
|
147
|
+
import { ACCOUNT_RETURN_KEY, safeAccountReturn } from "../../utils/account-return";
|
|
134
148
|
|
|
135
149
|
const props = defineProps({
|
|
136
150
|
hideNavIcon: {
|
|
@@ -246,6 +260,41 @@ const profile = computed(() => {
|
|
|
246
260
|
return `/api/public/${currentUser.value?.profile}`;
|
|
247
261
|
});
|
|
248
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Manage Account carries the page the user is on, so the Account application
|
|
265
|
+
* can offer a way back to it (DV-1874). It opens Personal Info directly:
|
|
266
|
+
* `/home` is a server redirect there that would drop the query.
|
|
267
|
+
*/
|
|
268
|
+
function openAccount() {
|
|
269
|
+
redirect(
|
|
270
|
+
APP_ACCOUNT,
|
|
271
|
+
`personal-info?return=${encodeURIComponent(window.location.href)}`
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* In the Account application, the Back target: taken from `?return=` when it
|
|
277
|
+
* arrives (and only if it is one of our own apps), then kept for the tab's
|
|
278
|
+
* session so it survives moving between the Personal Info screens, which drop
|
|
279
|
+
* the query. Read in `onMounted` - the bar is pre-rendered on the server,
|
|
280
|
+
* where there is no `window` or `sessionStorage`.
|
|
281
|
+
*/
|
|
282
|
+
const accountReturn = ref("");
|
|
283
|
+
|
|
284
|
+
onMounted(() => {
|
|
285
|
+
if (APP_NAME.toLowerCase() !== "account") return;
|
|
286
|
+
try {
|
|
287
|
+
const fromQuery = safeAccountReturn(route.query.return, String(APP_ACCOUNT));
|
|
288
|
+
if (fromQuery) sessionStorage.setItem(ACCOUNT_RETURN_KEY, fromQuery);
|
|
289
|
+
accountReturn.value =
|
|
290
|
+
fromQuery ||
|
|
291
|
+
safeAccountReturn(sessionStorage.getItem(ACCOUNT_RETURN_KEY), String(APP_ACCOUNT));
|
|
292
|
+
} catch {
|
|
293
|
+
// Storage blocked (private mode): fall back to the query alone.
|
|
294
|
+
accountReturn.value = safeAccountReturn(route.query.return, String(APP_ACCOUNT));
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
|
|
249
298
|
function logout() {
|
|
250
299
|
if (APP_NAME.toLowerCase() !== "main") {
|
|
251
300
|
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.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.736",
|
|
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,51 @@
|
|
|
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";
|