@7365admin1/layer-common 4.189.0 → 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 +16 -4
- package/components/AreaFormDialog.vue +8 -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,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 4.189.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 2f46655: Add Area / Add Unit popup stays open and shows "Required" when Create is clicked with an empty name, instead of closing without a message.
|
|
14
|
+
|
|
3
15
|
## 4.189.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -4142,11 +4154,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
|
|
|
4142
4154
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
4143
4155
|
own rule from two endpoints the console already calls, unprojected:
|
|
4144
4156
|
|
|
4145
|
-
|
|
4146
|
-
|
|
4157
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
4158
|
+
GET /api/roles/id/:role that membership's role document
|
|
4147
4159
|
|
|
4148
|
-
|
|
4149
|
-
|
|
4160
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
4161
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
4150
4162
|
|
|
4151
4163
|
`role.default` is the marker because it is the only property of a platform
|
|
4152
4164
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
/>
|
|
59
59
|
<v-text-field
|
|
60
60
|
v-model="model"
|
|
61
|
-
:rules="[
|
|
61
|
+
:rules="[nameRequiredRule]"
|
|
62
62
|
class="filter-field mb-0"
|
|
63
63
|
/>
|
|
64
64
|
</v-col>
|
|
@@ -149,7 +149,6 @@
|
|
|
149
149
|
|
|
150
150
|
<script setup lang="ts">
|
|
151
151
|
import useUnits from '../composables/useUnits';
|
|
152
|
-
import useUtils from '../composables/useUtils';
|
|
153
152
|
|
|
154
153
|
const model = defineModel("name", { type: String, default: "" });
|
|
155
154
|
const typeModel = defineModel("type", { type: String, default: "Common" });
|
|
@@ -185,7 +184,8 @@ const valid = ref(false);
|
|
|
185
184
|
const submitting = ref(false);
|
|
186
185
|
const show = ref(false);
|
|
187
186
|
|
|
188
|
-
|
|
187
|
+
// Spaces only is still an empty name.
|
|
188
|
+
const nameRequiredRule = (v: any) => !!String(v ?? "").trim() || "Required";
|
|
189
189
|
|
|
190
190
|
const unitsRequiredRule = (v: any) => {
|
|
191
191
|
if (Array.isArray(v)) return v.length > 0 || "Select at least one unit";
|
|
@@ -237,7 +237,11 @@ async function submit() {
|
|
|
237
237
|
let ok = valid.value;
|
|
238
238
|
if (form && typeof form.validate === "function") {
|
|
239
239
|
try {
|
|
240
|
-
|
|
240
|
+
// Vuetify 3 resolves to `{ valid, errors }`, an object that is always
|
|
241
|
+
// truthy: reading it as the result let an empty name through and closed
|
|
242
|
+
// the popup without saving or saying anything (DV-1872).
|
|
243
|
+
const result = await form.validate();
|
|
244
|
+
ok = typeof result === "object" && result !== null ? !!result.valid : !!result;
|
|
241
245
|
} catch (e) {
|
|
242
246
|
ok = false;
|
|
243
247
|
}
|
|
@@ -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";
|