@jskit-ai/users-web 0.2.111 → 0.2.112
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 +1 -0
- package/locales/en.json +14 -1
- package/package.json +7 -7
- package/src/client/account-settings/DeleteAccountSection.vue +88 -0
- package/src/client/account-settings/sections.js +4 -2
- package/src/client/providers/UsersWebClientProvider.js +3 -0
- package/test/accountSettingsSections.test.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- `users.web.account.delete`, the account settings section that deletes the account (with the store subscriptions notice and, inside the app, a fresh Apple authorization code from the phone's sheet), and the `delete-account` section's icon and summary.
|
|
5
6
|
- The account settings know `push-web`'s section, `push`: its icon (`$notifications`) and its line in the list, "Notifications on your phones and browsers" (`jskit.users.accountSettings.summary.push`).
|
|
6
7
|
- The open section's row in the account settings section list keeps an icon tile on its Material 3 active indicator, the `secondary-container` pill as tall as the row with its label bold and in `on-secondary-container`, which no other row has: the open section's tile is filled `primary` with its icon in `on-primary`, and every other row's stays `primary-container` with its icon in `on-primary-container`. `primary-container` shares the pill's tone (90 in light, 30 in dark), so it would show on the pill only where a seed's hues differ (1.01:1 for the default seed in light); `primary` (40, 80 in dark) stands out of it at least 3:1 for any seed, in light and dark. In 0.2.140 the open section's tile had no fill of its own and its icon was in `on-secondary-container`, so the tile disappeared into the pill (#504). The `users/account-settings` pattern says the same.
|
|
7
8
|
- Account settings' forms follow the guide's edit-form rule (#504). **Behaviour change:** leaving a section's form with edits the person has not saved asks first: its close, Done, another section and the browser's Back open a "Discard unsaved changes?" dialog (Keep editing stays; Discard gives the form its saved values back and goes on; new message keys `jskit.users.accountSettings.discard.title`, `.text`, `.keepEditing` and `.confirm`), and closing or reloading the tab asks through the browser. The runtime answers `hasUnsavedEdits` and `discardEdits()` for its three forms, and each of `profile`, `preferences` and `notifications` its own `hasUnsavedEdits` (a ref; http-web's new `useAddEdit()` `hasUnsavedEdits`). The `users/account-settings` pattern's Profile, Preferences and Notifications sections are edit forms: each calls shell-web's `useShellPageClose()`, so the bar's Up arrow is its close (X), Cancel, which leaves for the list (Sign-in methods, no form, keeps the arrow), and its Save says what it saves (**Save profile**, **Save preferences**, **Save notifications**) and stays off until a field changes. Upgrading: an app's copy of the pattern's sections keeps working and already asks before unsaved edits are left; copy the sections' `useShellPageClose()` call and their Save's `label` and `disabled` for the close and the named Save that waits for a change. The question names the section ("Your changes to Profile will be lost."), its text 16dp under its headline. The section list's account header shows the account as saved (the runtime's new `account.saved` and `account.initials`), not the name the person is typing. On an expanded or large window, the list's own page (`/account`, the first section beside the list) draws the same bar as that section's page: no Up arrow, and Done as the way out, where it had Up to the list's parent and no Done.
|
package/locales/en.json
CHANGED
|
@@ -80,11 +80,24 @@
|
|
|
80
80
|
"preferences": "Theme, language and formats",
|
|
81
81
|
"notifications": "Updates and alerts we send you",
|
|
82
82
|
"push": "Notifications on your phones and browsers",
|
|
83
|
-
"signInMethods": "Password and linked accounts"
|
|
83
|
+
"signInMethods": "Password and linked accounts",
|
|
84
|
+
"deleteAccount": "Delete your account and its data"
|
|
84
85
|
}
|
|
85
86
|
},
|
|
86
87
|
"homeTools": {
|
|
87
88
|
"label": "Home cog"
|
|
89
|
+
},
|
|
90
|
+
"deleteAccount": {
|
|
91
|
+
"explain": "Deleting your account removes it and its data for good. You'll be signed out on every device.",
|
|
92
|
+
"subscriptions": "A subscription you bought in the App Store or Google Play isn't cancelled by deleting your account. Cancel it in your store's subscriptions.",
|
|
93
|
+
"appleSubscriptions": "App Store subscriptions",
|
|
94
|
+
"googleSubscriptions": "Google Play subscriptions",
|
|
95
|
+
"start": "Delete account",
|
|
96
|
+
"password": "Password",
|
|
97
|
+
"passwordHint": "If you sign in with Google or Apple, leave it empty: a recent sign-in confirms it's you.",
|
|
98
|
+
"confirm": "Delete my account for good",
|
|
99
|
+
"cancel": "Cancel",
|
|
100
|
+
"failed": "Your account wasn't deleted. Try again."
|
|
88
101
|
}
|
|
89
102
|
}
|
|
90
103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/users-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.112",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"./locales/en.json": "./locales/en.json"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@jskit-ai/uploads-image-web": "0.2.
|
|
17
|
-
"@jskit-ai/users-core": "0.2.
|
|
16
|
+
"@jskit-ai/uploads-image-web": "0.2.42",
|
|
17
|
+
"@jskit-ai/users-core": "0.2.85"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@jskit-ai/auth-web": "0.2.
|
|
21
|
-
"@jskit-ai/http-runtime": "0.2.
|
|
22
|
-
"@jskit-ai/http-web": "0.2.
|
|
20
|
+
"@jskit-ai/auth-web": "0.2.81",
|
|
21
|
+
"@jskit-ai/http-runtime": "0.2.43",
|
|
22
|
+
"@jskit-ai/http-web": "0.2.84",
|
|
23
23
|
"@jskit-ai/kernel": "0.2.41",
|
|
24
|
-
"@jskit-ai/shell-web": "0.2.
|
|
24
|
+
"@jskit-ai/shell-web": "0.2.73",
|
|
25
25
|
"@tanstack/vue-query": "^5.90.5",
|
|
26
26
|
"vue": "^3.5.13",
|
|
27
27
|
"vue-router": "^5.0.4",
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import { useAuthOAuthLaunchClient } from "@jskit-ai/auth-web/client";
|
|
4
|
+
import { signOutAppCredentials } from "@jskit-ai/http-runtime/client";
|
|
5
|
+
import { getHttpWebClient } from "@jskit-ai/http-web/client";
|
|
6
|
+
import { useJskitText } from "../i18n.js";
|
|
7
|
+
|
|
8
|
+
// Deleting the signed-in person's own account, from the account settings (App Store guideline 5.1.1(v)): the password
|
|
9
|
+
// (empty for an account that signs in with Google or Apple, which needs a recent sign-in instead), then
|
|
10
|
+
// DELETE /api/account. An account linked to Apple asks the phone's Apple sheet for a fresh code, which revokes it at
|
|
11
|
+
// Apple. A store subscription is the store's to cancel. Place it at `account-settings:sections` as
|
|
12
|
+
// `users.web.account.delete`, with value "delete-account".
|
|
13
|
+
const { t, serverMessage } = useJskitText();
|
|
14
|
+
const launch = useAuthOAuthLaunchClient();
|
|
15
|
+
|
|
16
|
+
const confirming = ref(false);
|
|
17
|
+
const password = ref("");
|
|
18
|
+
const deleting = ref(false);
|
|
19
|
+
const error = ref("");
|
|
20
|
+
|
|
21
|
+
const STORE_SUBSCRIPTIONS = Object.freeze({
|
|
22
|
+
apple: "https://apps.apple.com/account/subscriptions",
|
|
23
|
+
google: "https://play.google.com/store/account/subscriptions"
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
function request(body) {
|
|
27
|
+
return getHttpWebClient().request("/api/account", { method: "DELETE", body });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function deleteAccount() {
|
|
31
|
+
deleting.value = true;
|
|
32
|
+
error.value = "";
|
|
33
|
+
const body = password.value ? { password: password.value } : {};
|
|
34
|
+
try {
|
|
35
|
+
try {
|
|
36
|
+
await request(body);
|
|
37
|
+
} catch (refusal) {
|
|
38
|
+
if (refusal?.code !== "auth.local.account.appleReauthRequired") throw refusal;
|
|
39
|
+
const appleAuthorizationCode = await launch.reauthorizeNatively("apple");
|
|
40
|
+
if (!appleAuthorizationCode) throw refusal;
|
|
41
|
+
await request({ ...body, appleAuthorizationCode });
|
|
42
|
+
}
|
|
43
|
+
// Inside an app its tokens are forgotten; on the web this does nothing.
|
|
44
|
+
await signOutAppCredentials().catch(() => {});
|
|
45
|
+
globalThis.location?.assign("/");
|
|
46
|
+
} catch (refusal) {
|
|
47
|
+
error.value = serverMessage(refusal, t("jskit.users.deleteAccount.failed"));
|
|
48
|
+
} finally {
|
|
49
|
+
deleting.value = false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<div class="delete-account-section">
|
|
56
|
+
<p class="text-body-1 mb-4">{{ t("jskit.users.deleteAccount.explain") }}</p>
|
|
57
|
+
<v-alert type="info" variant="tonal" class="mb-4">
|
|
58
|
+
{{ t("jskit.users.deleteAccount.subscriptions") }}
|
|
59
|
+
<div class="mt-2">
|
|
60
|
+
<a :href="STORE_SUBSCRIPTIONS.apple" target="_blank" rel="noopener" class="mr-4">{{ t("jskit.users.deleteAccount.appleSubscriptions") }}</a>
|
|
61
|
+
<a :href="STORE_SUBSCRIPTIONS.google" target="_blank" rel="noopener">{{ t("jskit.users.deleteAccount.googleSubscriptions") }}</a>
|
|
62
|
+
</div>
|
|
63
|
+
</v-alert>
|
|
64
|
+
<v-btn v-if="!confirming" color="error" variant="tonal" @click="confirming = true">{{ t("jskit.users.deleteAccount.start") }}</v-btn>
|
|
65
|
+
<v-form v-else novalidate @submit.prevent="deleteAccount">
|
|
66
|
+
<v-text-field
|
|
67
|
+
v-model="password"
|
|
68
|
+
type="password"
|
|
69
|
+
autocomplete="current-password"
|
|
70
|
+
:label="t('jskit.users.deleteAccount.password')"
|
|
71
|
+
:hint="t('jskit.users.deleteAccount.passwordHint')"
|
|
72
|
+
persistent-hint
|
|
73
|
+
:disabled="deleting"
|
|
74
|
+
/>
|
|
75
|
+
<v-alert v-if="error" type="error" variant="tonal" class="my-4" role="alert">{{ error }}</v-alert>
|
|
76
|
+
<div class="d-flex ga-2 mt-4">
|
|
77
|
+
<v-btn type="submit" color="error" :loading="deleting">{{ t("jskit.users.deleteAccount.confirm") }}</v-btn>
|
|
78
|
+
<v-btn variant="text" :disabled="deleting" @click="confirming = false">{{ t("jskit.users.deleteAccount.cancel") }}</v-btn>
|
|
79
|
+
</div>
|
|
80
|
+
</v-form>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<style scoped>
|
|
85
|
+
.delete-account-section {
|
|
86
|
+
padding: 1rem 0;
|
|
87
|
+
}
|
|
88
|
+
</style>
|
|
@@ -20,7 +20,8 @@ const ACCOUNT_SETTINGS_SECTION_ICONS = Object.freeze({
|
|
|
20
20
|
notifications: "$notifications",
|
|
21
21
|
// push-web's notifications on phones and browsers (push.web.settings.section).
|
|
22
22
|
push: "$notifications",
|
|
23
|
-
"sign-in-methods": "$key"
|
|
23
|
+
"sign-in-methods": "$key",
|
|
24
|
+
"delete-account": "$delete"
|
|
24
25
|
});
|
|
25
26
|
const ACCOUNT_SETTINGS_SECTION_ICON = "$settings";
|
|
26
27
|
// The line under the title of each section the account-settings pattern places, for a placement that names none, as a
|
|
@@ -30,7 +31,8 @@ const ACCOUNT_SETTINGS_SECTION_SUMMARIES = Object.freeze({
|
|
|
30
31
|
preferences: "jskit.users.accountSettings.summary.preferences",
|
|
31
32
|
notifications: "jskit.users.accountSettings.summary.notifications",
|
|
32
33
|
push: "jskit.users.accountSettings.summary.push",
|
|
33
|
-
"sign-in-methods": "jskit.users.accountSettings.summary.signInMethods"
|
|
34
|
+
"sign-in-methods": "jskit.users.accountSettings.summary.signInMethods",
|
|
35
|
+
"delete-account": "jskit.users.accountSettings.summary.deleteAccount"
|
|
34
36
|
});
|
|
35
37
|
|
|
36
38
|
// A section title is plain text, a message key or { key, fallback, params };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineProvider } from "@jskit-ai/kernel/shared/capabilities";
|
|
2
2
|
import UsersHomeToolsWidget from "../components/UsersHomeToolsWidget.vue";
|
|
3
3
|
import ProfileClientElement from "../components/ProfileClientElement.vue";
|
|
4
|
+
import { defineAsyncComponent } from "vue";
|
|
4
5
|
import { createUsersBootstrapUserHandler } from "../bootstrap/user-bootstrap-handler.js";
|
|
5
6
|
|
|
6
7
|
const UsersWebClientProvider = defineProvider({
|
|
@@ -18,6 +19,8 @@ const UsersWebClientProvider = defineProvider({
|
|
|
18
19
|
setup({ components, shell }) {
|
|
19
20
|
components.register("users.web.home.tools.widget", UsersHomeToolsWidget);
|
|
20
21
|
components.register("users.web.profile.element", ProfileClientElement);
|
|
22
|
+
// Loaded only when the account settings open it.
|
|
23
|
+
components.register("users.web.account.delete", defineAsyncComponent(() => import("../account-settings/DeleteAccountSection.vue")));
|
|
21
24
|
shell.bootstrapHandlers.register(createUsersBootstrapUserHandler());
|
|
22
25
|
}
|
|
23
26
|
});
|
|
@@ -125,6 +125,7 @@ test("each section has its icon: the placement's own, else users-web's for its o
|
|
|
125
125
|
section("notifications"),
|
|
126
126
|
section("push"),
|
|
127
127
|
section("sign-in-methods"),
|
|
128
|
+
section("delete-account"),
|
|
128
129
|
section("billing"),
|
|
129
130
|
section("invites", "$mail"),
|
|
130
131
|
section("security", " $lock ")
|
|
@@ -135,6 +136,7 @@ test("each section has its icon: the placement's own, else users-web's for its o
|
|
|
135
136
|
notifications: "$notifications",
|
|
136
137
|
push: "$notifications",
|
|
137
138
|
"sign-in-methods": "$key",
|
|
139
|
+
"delete-account": "$delete",
|
|
138
140
|
billing: "$settings",
|
|
139
141
|
invites: "$mail",
|
|
140
142
|
security: "$lock"
|
|
@@ -162,6 +164,7 @@ test("each section has its one-line summary: the placement's own, else users-web
|
|
|
162
164
|
section("notifications"),
|
|
163
165
|
section("push"),
|
|
164
166
|
section("sign-in-methods"),
|
|
167
|
+
section("delete-account"),
|
|
165
168
|
section("billing"),
|
|
166
169
|
section("invites", " People you invited "),
|
|
167
170
|
section("security", { key: "app.settings.security.summary", fallback: "Two-step sign-in" })
|
|
@@ -172,6 +175,7 @@ test("each section has its one-line summary: the placement's own, else users-web
|
|
|
172
175
|
notifications: "jskit.users.accountSettings.summary.notifications",
|
|
173
176
|
push: "jskit.users.accountSettings.summary.push",
|
|
174
177
|
"sign-in-methods": "jskit.users.accountSettings.summary.signInMethods",
|
|
178
|
+
"delete-account": "jskit.users.accountSettings.summary.deleteAccount",
|
|
175
179
|
billing: "",
|
|
176
180
|
invites: "People you invited",
|
|
177
181
|
security: { key: "app.settings.security.summary", fallback: "Two-step sign-in" }
|