@frigear-nu/users 3.1.5 → 3.1.6
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/dist/module.d.mts +103 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +132 -16
- package/dist/runtime/access.js +3 -3
- package/dist/runtime/app/components/UserCreateSlideover.vue +8 -6
- package/dist/runtime/app/components/UserPicker.d.vue.ts +2 -2
- package/dist/runtime/app/components/UserPicker.vue.d.ts +2 -2
- package/dist/runtime/app/components/UsersAdminTerms.d.vue.ts +7 -0
- package/dist/runtime/app/components/UsersAdminTerms.vue +55 -0
- package/dist/runtime/app/components/UsersAdminTerms.vue.d.ts +7 -0
- package/dist/runtime/app/components/UsersTermsGate.d.vue.ts +11 -0
- package/dist/runtime/app/components/UsersTermsGate.vue +82 -0
- package/dist/runtime/app/components/UsersTermsGate.vue.d.ts +11 -0
- package/dist/runtime/app/components/UsersTermsText.d.vue.ts +7 -0
- package/dist/runtime/app/components/UsersTermsText.vue +34 -0
- package/dist/runtime/app/components/UsersTermsText.vue.d.ts +7 -0
- package/dist/runtime/app/composables/useUserActions.d.ts +6 -2
- package/dist/runtime/app/composables/useUserActions.js +32 -3
- package/dist/runtime/app/pages/admin-user.vue +3 -0
- package/dist/runtime/app/pages/admin.vue +2 -1
- package/dist/runtime/app/pages/revert-email-change.vue +2 -1
- package/dist/runtime/app/plugins/terms-gate.client.d.ts +2 -0
- package/dist/runtime/app/plugins/terms-gate.client.js +55 -0
- package/dist/runtime/app/tabs/Overview.vue +22 -12
- package/dist/runtime/app/utils/admin-user.d.ts +4 -2
- package/dist/runtime/app/utils/terms.d.ts +10 -0
- package/dist/runtime/app/utils/terms.js +7 -0
- package/dist/runtime/app/widgets/NewUsers.d.vue.ts +4 -1
- package/dist/runtime/app/widgets/NewUsers.vue +7 -4
- package/dist/runtime/app/widgets/NewUsers.vue.d.ts +4 -1
- package/dist/runtime/app/widgets/NewUsersStat.d.vue.ts +4 -1
- package/dist/runtime/app/widgets/NewUsersStat.vue +4 -1
- package/dist/runtime/app/widgets/NewUsersStat.vue.d.ts +4 -1
- package/dist/runtime/app/widgets/UsersAccountTerms.d.vue.ts +6 -0
- package/dist/runtime/app/widgets/UsersAccountTerms.vue +63 -0
- package/dist/runtime/app/widgets/UsersAccountTerms.vue.d.ts +6 -0
- package/dist/runtime/app/widgets/UsersRegisterTerms.d.vue.ts +9 -0
- package/dist/runtime/app/widgets/UsersRegisterTerms.vue +37 -0
- package/dist/runtime/app/widgets/UsersRegisterTerms.vue.d.ts +9 -0
- package/dist/runtime/db/terms-users.postgresql.d.ts +24 -0
- package/dist/runtime/db/terms-users.postgresql.js +4 -0
- package/dist/runtime/db/terms-users.sqlite.d.ts +26 -0
- package/dist/runtime/db/terms-users.sqlite.js +4 -0
- package/dist/runtime/db/terms.postgresql.d.ts +162 -0
- package/dist/runtime/db/terms.postgresql.js +21 -0
- package/dist/runtime/db/terms.sqlite.d.ts +173 -0
- package/dist/runtime/db/terms.sqlite.js +21 -0
- package/dist/runtime/i18n/lang/da.json +62 -3
- package/dist/runtime/i18n/lang/en.json +62 -3
- package/dist/runtime/server/plugins/terms-claims.d.ts +13 -0
- package/dist/runtime/server/plugins/terms-claims.js +19 -0
- package/dist/runtime/server/plugins/terms.d.ts +15 -0
- package/dist/runtime/server/plugins/terms.js +43 -0
- package/dist/runtime/server/routes/admin/user-avatar.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/user-avatar.delete.js +11 -0
- package/dist/runtime/server/routes/admin/user-terms.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/user-terms.get.js +12 -0
- package/dist/runtime/server/routes/admin/user.delete.js +2 -0
- package/dist/runtime/server/routes/admin/user.patch.js +2 -2
- package/dist/runtime/server/routes/admin/users.get.js +1 -2
- package/dist/runtime/server/routes/avatar.get.d.ts +2 -0
- package/dist/runtime/server/routes/avatar.get.js +12 -0
- package/dist/runtime/server/routes/me/avatar.delete.d.ts +2 -0
- package/dist/runtime/server/routes/me/avatar.delete.js +13 -0
- package/dist/runtime/server/routes/me/avatar.put.d.ts +2 -0
- package/dist/runtime/server/routes/me/avatar.put.js +20 -0
- package/dist/runtime/server/routes/me/profile.patch.js +7 -2
- package/dist/runtime/server/routes/me/terms.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/terms.get.js +4 -0
- package/dist/runtime/server/routes/me/terms.post.d.ts +2 -0
- package/dist/runtime/server/routes/me/terms.post.js +18 -0
- package/dist/runtime/server/schemas.d.ts +5 -1
- package/dist/runtime/server/schemas.js +2 -1
- package/dist/runtime/server/utils/dto.d.ts +1 -1
- package/dist/runtime/server/utils/dto.js +2 -1
- package/dist/runtime/server/utils/users-avatar.d.ts +29 -0
- package/dist/runtime/server/utils/users-avatar.js +69 -0
- package/dist/runtime/server/utils/users-terms.d.ts +35 -0
- package/dist/runtime/server/utils/users-terms.js +90 -0
- package/dist/runtime/utils/api.d.ts +21 -2
- package/dist/runtime/utils/api.js +20 -1
- package/dist/runtime/utils/avatar.d.ts +25 -0
- package/dist/runtime/utils/avatar.js +23 -0
- package/dist/runtime/utils/terms-claim.d.ts +27 -0
- package/dist/runtime/utils/terms-claim.js +15 -0
- package/dist/types.d.mts +1 -1
- package/package.json +18 -13
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { splitUsersTermsText, usersTermsLinkParams } from "../utils/terms";
|
|
4
|
+
import { useLocaleLink, useModuleT } from "#imports";
|
|
5
|
+
defineOptions({ name: "UsersTermsText" });
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
terms: { type: Object, required: true }
|
|
8
|
+
});
|
|
9
|
+
const t = useModuleT("users");
|
|
10
|
+
const { localize } = useLocaleLink();
|
|
11
|
+
const parts = computed(() => {
|
|
12
|
+
const links = usersTermsLinkParams("terms", "privacy");
|
|
13
|
+
const sentence = props.terms.privacyUrl ? t("terms.acceptWithPrivacy", "I accept the {terms} and have read the {privacy}.", links) : t("terms.accept", "I accept the {terms}.", links);
|
|
14
|
+
return splitUsersTermsText(sentence);
|
|
15
|
+
});
|
|
16
|
+
const linkOf = (name) => name === "privacy" ? { to: localize(props.terms.privacyUrl ?? ""), label: t("terms.privacyLink", "privacy policy") } : { to: localize(props.terms.url), label: t("terms.termsLink", "terms") };
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<span>
|
|
21
|
+
<template
|
|
22
|
+
v-for="(part, index) in parts"
|
|
23
|
+
:key="index"
|
|
24
|
+
>
|
|
25
|
+
<ULink
|
|
26
|
+
v-if="'link' in part"
|
|
27
|
+
:to="linkOf(part.link).to"
|
|
28
|
+
target="_blank"
|
|
29
|
+
class="text-primary font-medium underline-offset-2 hover:underline"
|
|
30
|
+
>{{ linkOf(part.link).label }}</ULink>
|
|
31
|
+
<template v-else>{{ part.text }}</template>
|
|
32
|
+
</template>
|
|
33
|
+
</span>
|
|
34
|
+
</template>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UsersPublicTerms } from '../../../types.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
terms: UsersPublicTerms;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -5,6 +5,8 @@ export interface UserMenuOptions {
|
|
|
5
5
|
extra?: DropdownMenuItem[][];
|
|
6
6
|
/** Runs after the user was deleted; without it the users list is refreshed. */
|
|
7
7
|
onRemoved?: () => void | Promise<void>;
|
|
8
|
+
/** Runs after the user's avatar was removed; without it the users list is refreshed. */
|
|
9
|
+
onAvatarRemoved?: () => void | Promise<void>;
|
|
8
10
|
/** Leave out "Open", e.g. on the user's own page. Default `true`. */
|
|
9
11
|
open?: boolean;
|
|
10
12
|
/** Hide the entries the acting staff member may not use (known on the detail page). Both default to `true`. */
|
|
@@ -14,14 +16,16 @@ export interface UserMenuOptions {
|
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
|
-
* Everything staff do to a user: `create` (a slideover, then the new user's page), `remove` (confirm, toast, refresh)
|
|
18
|
-
* `RowMenu` of the list rows and the detail heading, ordered Open,
|
|
19
|
+
* Everything staff do to a user: `create` (a slideover, then the new user's page), `remove` (confirm, toast, refresh),
|
|
20
|
+
* `removeAvatar` (the same) and `menu(user)` for the `RowMenu` of the list rows and the detail heading, ordered Open,
|
|
21
|
+
* sign-in link, extras, then Remove avatar and Delete in their own group.
|
|
19
22
|
*/
|
|
20
23
|
export declare function useUserActions(): {
|
|
21
24
|
listPath: import("vue").ComputedRef<any>;
|
|
22
25
|
userPath: (id: number) => string;
|
|
23
26
|
create: () => Promise<UserRow | false>;
|
|
24
27
|
remove: (user: UserSubject, options?: Pick<UserMenuOptions, "onRemoved">) => Promise<boolean>;
|
|
28
|
+
removeAvatar: (user: UserSubject, options?: Pick<UserMenuOptions, "onAvatarRemoved">) => Promise<boolean>;
|
|
25
29
|
resend: (user: UserSubject) => Promise<boolean>;
|
|
26
30
|
menu: (user: UserSubject, options?: UserMenuOptions) => DropdownMenuItem[][];
|
|
27
31
|
};
|
|
@@ -34,6 +34,23 @@ export function useUserActions() {
|
|
|
34
34
|
else await refreshNuxtData(ADMIN_USERS_KEY);
|
|
35
35
|
return true;
|
|
36
36
|
}
|
|
37
|
+
async function removeAvatar(user, options = {}) {
|
|
38
|
+
const confirmed = await confirm({
|
|
39
|
+
title: t("admin.removeAvatarTitle", "Remove the avatar of {name}?", { name: user.name }),
|
|
40
|
+
description: t("admin.removeAvatarBody", "The photo disappears from their profile everywhere in the app, and an uploaded photo is deleted. They can add a new one."),
|
|
41
|
+
confirmText: t("admin.removeAvatar", "Remove avatar"),
|
|
42
|
+
destructive: true
|
|
43
|
+
});
|
|
44
|
+
if (!confirmed) return false;
|
|
45
|
+
const done = await run(
|
|
46
|
+
() => $fetch(usersApi.admin.avatar(user.id), { method: "DELETE" }).then(() => true),
|
|
47
|
+
{ success: t("admin.avatarRemoved", "Removed the avatar of {name}", { name: user.name }) }
|
|
48
|
+
);
|
|
49
|
+
if (!done) return false;
|
|
50
|
+
if (options.onAvatarRemoved) await options.onAvatarRemoved();
|
|
51
|
+
else await refreshNuxtData(ADMIN_USERS_KEY);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
37
54
|
async function resend(user) {
|
|
38
55
|
const sent = await run(
|
|
39
56
|
() => $fetch(usersApi.admin.resend(user.id), { method: "POST" }).then(() => true),
|
|
@@ -60,17 +77,29 @@ export function useUserActions() {
|
|
|
60
77
|
}
|
|
61
78
|
if (first.length) groups.push(first);
|
|
62
79
|
groups.push(...(options.extra ?? []).filter((group) => group.length));
|
|
80
|
+
const destructive = [];
|
|
81
|
+
if (canUpdate && user.avatar) {
|
|
82
|
+
destructive.push({
|
|
83
|
+
label: t("admin.removeAvatar", "Remove avatar"),
|
|
84
|
+
icon: "i-lucide-image-off",
|
|
85
|
+
color: "error",
|
|
86
|
+
onSelect: () => {
|
|
87
|
+
void removeAvatar(user, { onAvatarRemoved: options.onAvatarRemoved });
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
63
91
|
if (canDelete) {
|
|
64
|
-
|
|
92
|
+
destructive.push({
|
|
65
93
|
label: t("admin.deleteUser", "Delete user"),
|
|
66
94
|
icon: "i-lucide-trash-2",
|
|
67
95
|
color: "error",
|
|
68
96
|
onSelect: () => {
|
|
69
97
|
void remove(user, { onRemoved: options.onRemoved });
|
|
70
98
|
}
|
|
71
|
-
}
|
|
99
|
+
});
|
|
72
100
|
}
|
|
101
|
+
if (destructive.length) groups.push(destructive);
|
|
73
102
|
return groups;
|
|
74
103
|
}
|
|
75
|
-
return { listPath, userPath, create, remove, resend, menu };
|
|
104
|
+
return { listPath, userPath, create, remove, removeAvatar, resend, menu };
|
|
76
105
|
}
|
|
@@ -102,9 +102,10 @@ const addUser = () => actions.create();
|
|
|
102
102
|
<div class="flex flex-col gap-4">
|
|
103
103
|
<PageHeading :title="t('admin.title', 'Users')">
|
|
104
104
|
<template #actions>
|
|
105
|
-
<
|
|
105
|
+
<TooltipButton
|
|
106
106
|
icon="i-lucide-plus"
|
|
107
107
|
:label="t('admin.create', 'Add user')"
|
|
108
|
+
:tooltip="t('admin.createButtonHint', 'Create an account, with a welcome email if you choose')"
|
|
108
109
|
@click="addUser"
|
|
109
110
|
/>
|
|
110
111
|
</template>
|
|
@@ -93,11 +93,12 @@ async function onRevert() {
|
|
|
93
93
|
variant="subtle"
|
|
94
94
|
:title="error"
|
|
95
95
|
/>
|
|
96
|
-
<
|
|
96
|
+
<TooltipButton
|
|
97
97
|
block
|
|
98
98
|
color="error"
|
|
99
99
|
:loading="reverting"
|
|
100
100
|
:label="t('revert.submit', 'Restore {email}', { email: preview.oldEmail })"
|
|
101
|
+
:tooltip="t('revert.submitHint', 'Your account goes back to this address; you may be signed out')"
|
|
101
102
|
@click="onRevert"
|
|
102
103
|
/>
|
|
103
104
|
</template>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { watch } from "vue";
|
|
2
|
+
import { usersApi } from "../../utils/api.js";
|
|
3
|
+
import UsersTermsGate from "../components/UsersTermsGate.vue";
|
|
4
|
+
import { $fetch, defineNuxtPlugin, useLocaleLink, useOverlay, useRouter, useRuntimeConfig, useUserSession } from "#imports";
|
|
5
|
+
export default defineNuxtPlugin({
|
|
6
|
+
name: "users:terms-gate",
|
|
7
|
+
setup(nuxtApp) {
|
|
8
|
+
const terms = useRuntimeConfig().public.users?.terms;
|
|
9
|
+
if (!terms) return;
|
|
10
|
+
nuxtApp.hook("app:mounted", () => {
|
|
11
|
+
nuxtApp.runWithContext(() => {
|
|
12
|
+
const { loggedIn, user } = useUserSession();
|
|
13
|
+
const router = useRouter();
|
|
14
|
+
const { isActive } = useLocaleLink();
|
|
15
|
+
const gate = useOverlay().create(UsersTermsGate, { destroyOnClose: true });
|
|
16
|
+
let status = null;
|
|
17
|
+
let open = false;
|
|
18
|
+
let checked;
|
|
19
|
+
const onLegalPage = () => isActive(terms.url) || !!terms.privacyUrl && isActive(terms.privacyUrl);
|
|
20
|
+
const sync = () => {
|
|
21
|
+
const needed = !!status && !status.upToDate && loggedIn.value && !onLegalPage();
|
|
22
|
+
if (needed && !open) {
|
|
23
|
+
open = true;
|
|
24
|
+
void gate.open({ status }).then((next) => {
|
|
25
|
+
open = false;
|
|
26
|
+
if (next) status = next;
|
|
27
|
+
});
|
|
28
|
+
} else if (!needed && open) {
|
|
29
|
+
open = false;
|
|
30
|
+
gate.close();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const check = async () => {
|
|
34
|
+
const id = user.value?.id;
|
|
35
|
+
if (!loggedIn.value || id === void 0) {
|
|
36
|
+
status = null;
|
|
37
|
+
checked = void 0;
|
|
38
|
+
return sync();
|
|
39
|
+
}
|
|
40
|
+
if (checked === id) return sync();
|
|
41
|
+
checked = id;
|
|
42
|
+
try {
|
|
43
|
+
status = await $fetch(usersApi.me.terms);
|
|
44
|
+
} catch {
|
|
45
|
+
status = null;
|
|
46
|
+
checked = void 0;
|
|
47
|
+
}
|
|
48
|
+
sync();
|
|
49
|
+
};
|
|
50
|
+
watch([loggedIn, () => user.value?.id], () => void check(), { immediate: true });
|
|
51
|
+
router.afterEach(() => sync());
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { usersApi } from "../../utils/api";
|
|
3
3
|
import { USER_PHONE_MAX_LENGTH, USER_PHONE_PATTERN } from "../../utils/phone";
|
|
4
|
+
import { phoneIssue } from "@frigear-nu/ui/phone";
|
|
4
5
|
import { USER_NICKNAME_MAX_LENGTH, USER_PEOPLE_NUMBER_MAX_LENGTH } from "../../utils/profile";
|
|
5
6
|
import { z } from "zod";
|
|
6
|
-
import
|
|
7
|
+
import UsersAdminTerms from "../components/UsersAdminTerms.vue";
|
|
8
|
+
import { $fetch, computed, reactive, resolveComponent, useAction, useFormat, useModuleT, useRuntimeConfig, watch } from "#imports";
|
|
7
9
|
defineOptions({ name: "UsersAdminOverviewTab" });
|
|
8
10
|
const props = defineProps({
|
|
9
11
|
user: { type: Object, required: true }
|
|
@@ -13,14 +15,17 @@ const t = useModuleT("users");
|
|
|
13
15
|
const format = useFormat();
|
|
14
16
|
const { busy: saving, run } = useAction();
|
|
15
17
|
const OverviewWidgets = resolveComponent("WidgetArea");
|
|
18
|
+
const terms = useRuntimeConfig().public.users?.terms;
|
|
19
|
+
const showTerms = computed(() => !!terms && props.user.phone !== void 0);
|
|
16
20
|
const overviewWidgets = typeof OverviewWidgets === "string" ? void 0 : OverviewWidgets;
|
|
17
21
|
const schema = z.object({
|
|
18
22
|
name: z.string().trim().min(1, t("admin.nameRequired", "Enter a name.")).max(120),
|
|
19
23
|
nickname: z.string().trim().max(USER_NICKNAME_MAX_LENGTH, t("admin.nicknameTooLong", "Use at most {max} characters.", { max: USER_NICKNAME_MAX_LENGTH })),
|
|
20
24
|
email: z.string().trim().email(t("admin.emailInvalid", "Enter a valid email address.")),
|
|
21
25
|
emailVerified: z.boolean(),
|
|
22
|
-
// The server's rule (`phoneField`)
|
|
23
|
-
|
|
26
|
+
// The server's rule (`phoneField`) and a full international number (`PhoneInput` writes `+4512345678`); empty
|
|
27
|
+
// clears it. A number stored before the country selector passes until it is changed.
|
|
28
|
+
phone: z.string().trim().max(USER_PHONE_MAX_LENGTH).regex(USER_PHONE_PATTERN, t("admin.phoneInvalid", "Enter a valid phone number.")).refine((value) => !value || value === (props.user.phone ?? "") || !phoneIssue(value), t("admin.phoneInvalid", "Enter a valid phone number.")),
|
|
24
29
|
// The server's rule (`peopleNumberField`): at most 64 characters; empty clears it.
|
|
25
30
|
peopleNumber: z.string().trim().max(USER_PEOPLE_NUMBER_MAX_LENGTH, t("admin.peopleNumberTooLong", "Use at most {max} characters.", { max: USER_PEOPLE_NUMBER_MAX_LENGTH }))
|
|
26
31
|
});
|
|
@@ -47,13 +52,13 @@ const mediaFacts = computed(() => [
|
|
|
47
52
|
{ key: "photoOptOut", label: t("admin.media.photos", "Photos"), value: props.user.photoOptOut ? t("admin.media.photosOptOut", "Do not photograph as the main subject") : t("admin.media.allowed", "No objection") },
|
|
48
53
|
{ key: "tagOptOut", label: t("admin.media.tagging", "Tagging online"), value: props.user.tagOptOut ? t("admin.media.taggingOptOut", "Do not tag in posts or photos") : t("admin.media.allowed", "No objection") }
|
|
49
54
|
]);
|
|
50
|
-
const dirty = computed(() => form.name !== props.user.name || form.nickname.trim() !== (props.user.nickname ?? "") || form.email !== props.user.email || form.emailVerified !== !!props.user.emailVerifiedAt || props.user.can.pii && form.phone.trim() !== (props.user.phone ?? "") ||
|
|
55
|
+
const dirty = computed(() => form.name !== props.user.name || form.nickname.trim() !== (props.user.nickname ?? "") || form.email !== props.user.email || form.emailVerified !== !!props.user.emailVerifiedAt || props.user.can.pii && form.phone.trim() !== (props.user.phone ?? "") || form.peopleNumber.trim() !== (props.user.peopleNumber ?? ""));
|
|
51
56
|
async function save(event) {
|
|
52
57
|
const { name, nickname, email, emailVerified, phone, peopleNumber } = event.data;
|
|
53
58
|
const emailChanged = email !== props.user.email;
|
|
54
59
|
const nicknameChanged = nickname !== (props.user.nickname ?? "");
|
|
55
60
|
const phoneChanged = props.user.can.pii && phone !== (props.user.phone ?? "");
|
|
56
|
-
const peopleNumberChanged =
|
|
61
|
+
const peopleNumberChanged = peopleNumber !== (props.user.peopleNumber ?? "");
|
|
57
62
|
const saved = await run(
|
|
58
63
|
() => $fetch(usersApi.admin.user(props.user.id), {
|
|
59
64
|
method: "PATCH",
|
|
@@ -143,16 +148,15 @@ async function save(event) {
|
|
|
143
148
|
:label="t('admin.phone', 'Phone')"
|
|
144
149
|
:description="t('admin.detail.phoneHelp', 'Used for text messages. Leave it empty to remove it.')"
|
|
145
150
|
>
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
class="w-full sm:max-w-sm"
|
|
151
|
+
<PhoneInput
|
|
152
|
+
:model-value="form.phone"
|
|
153
|
+
:country-label="t('admin.phoneCountry', 'Country')"
|
|
154
|
+
class="sm:max-w-sm"
|
|
151
155
|
:disabled="!user.can.pii"
|
|
156
|
+
@update:model-value="form.phone = $event ?? ''"
|
|
152
157
|
/>
|
|
153
158
|
</FormRow>
|
|
154
159
|
<FormRow
|
|
155
|
-
v-if="user.peopleNumber !== void 0"
|
|
156
160
|
name="peopleNumber"
|
|
157
161
|
:label="t('admin.peopleNumber', 'People number')"
|
|
158
162
|
:description="t('admin.detail.peopleNumberHelp', 'Their id in an external system, such as a volunteer system. Leave it empty to remove it.')"
|
|
@@ -161,7 +165,7 @@ async function save(event) {
|
|
|
161
165
|
v-model="form.peopleNumber"
|
|
162
166
|
autocomplete="off"
|
|
163
167
|
class="w-full sm:max-w-sm"
|
|
164
|
-
:disabled="!user.can.
|
|
168
|
+
:disabled="!user.can.update"
|
|
165
169
|
/>
|
|
166
170
|
</FormRow>
|
|
167
171
|
</UForm>
|
|
@@ -203,5 +207,11 @@ async function save(event) {
|
|
|
203
207
|
</SectionCard>
|
|
204
208
|
</div>
|
|
205
209
|
</div>
|
|
210
|
+
|
|
211
|
+
<UsersAdminTerms
|
|
212
|
+
v-if="showTerms && terms"
|
|
213
|
+
:user-id="user.id"
|
|
214
|
+
:current-version="terms.version"
|
|
215
|
+
/>
|
|
206
216
|
</div>
|
|
207
217
|
</template>
|
|
@@ -38,8 +38,10 @@ export type UserDetail = AdminUserDto & {
|
|
|
38
38
|
pii: boolean;
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
-
/** What the actions need of a user: the list rows and the detail both satisfy it. */
|
|
42
|
-
export type UserSubject = Pick<UserRow, 'id' | 'name' | 'emailVerifiedAt'
|
|
41
|
+
/** What the actions need of a user: the list rows and the detail both satisfy it. Without `avatar` there is no "Remove avatar". */
|
|
42
|
+
export type UserSubject = Pick<UserRow, 'id' | 'name' | 'emailVerifiedAt'> & {
|
|
43
|
+
avatar?: string | null;
|
|
44
|
+
};
|
|
43
45
|
/** The key of the list's `useFetch`, refreshed after a user is created or deleted. */
|
|
44
46
|
export declare const ADMIN_USERS_KEY = "admin-users";
|
|
45
47
|
/** What the create form closes with: the created user, the existing user staff chose after a 409, or `false` (cancelled). */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A part of a sentence: plain text, or the link named by its placeholder. */
|
|
2
|
+
export type UsersTermsTextPart = {
|
|
3
|
+
text: string;
|
|
4
|
+
} | {
|
|
5
|
+
link: string;
|
|
6
|
+
};
|
|
7
|
+
/** The placeholder values to translate a sentence with, so `splitUsersTermsText` can find the links again. */
|
|
8
|
+
export declare function usersTermsLinkParams(...names: string[]): Record<string, string>;
|
|
9
|
+
/** `translated` (made with `usersTermsLinkParams`) cut into text and link parts, in order. */
|
|
10
|
+
export declare function splitUsersTermsText(translated: string): UsersTermsTextPart[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const MARK = "\uE000";
|
|
2
|
+
export function usersTermsLinkParams(...names) {
|
|
3
|
+
return Object.fromEntries(names.map((name) => [name, `${MARK}${name}${MARK}`]));
|
|
4
|
+
}
|
|
5
|
+
export function splitUsersTermsText(translated) {
|
|
6
|
+
return translated.split(new RegExp(`${MARK}([^${MARK}]+)${MARK}`)).map((piece, index) => index % 2 ? { link: piece } : { text: piece }).filter((part) => "link" in part || part.text);
|
|
7
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
framed?: boolean;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
5
|
declare const _default: typeof __VLS_export;
|
|
3
6
|
export default _default;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { usersApi } from "../../utils/api";
|
|
3
3
|
import { statusColor, useFormat, useLazyFetch, useLocaleLink, useModuleT, useRuntimeConfig } from "#imports";
|
|
4
4
|
defineOptions({ name: "UsersNewUsersWidget" });
|
|
5
|
+
defineProps({
|
|
6
|
+
framed: { type: Boolean, required: false }
|
|
7
|
+
});
|
|
5
8
|
const t = useModuleT("users");
|
|
6
9
|
const format = useFormat();
|
|
7
10
|
const { localize } = useLocaleLink();
|
|
@@ -12,11 +15,11 @@ const { data: users, status } = useLazyFetch(usersApi.admin.new, { key: "admin-u
|
|
|
12
15
|
|
|
13
16
|
<template>
|
|
14
17
|
<ListCard
|
|
15
|
-
:title="t('admin.newUsers.title', 'New users')"
|
|
18
|
+
:title="framed ? void 0 : t('admin.newUsers.title', 'New users')"
|
|
16
19
|
:description="t('admin.newUsers.description', 'Signed up in the last 30 days.')"
|
|
17
|
-
:loading="status === 'pending' && !users?.length"
|
|
18
|
-
:is-empty="!users?.length"
|
|
19
|
-
:empty="t('admin.newUsers.empty', 'Nobody new yet.')"
|
|
20
|
+
:loading="(status === 'pending' || status === 'idle') && !users?.length"
|
|
21
|
+
:is-empty="(status === 'success' || status === 'error') && !users?.length"
|
|
22
|
+
:empty="status === 'error' ? t('admin.newUsers.error', 'Could not load the new users.') : t('admin.newUsers.empty', 'Nobody new yet.')"
|
|
20
23
|
:to="listPath"
|
|
21
24
|
:to-label="t('admin.allUsers', 'All users')"
|
|
22
25
|
>
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
framed?: boolean;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
5
|
declare const _default: typeof __VLS_export;
|
|
3
6
|
export default _default;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
framed?: boolean;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
5
|
declare const _default: typeof __VLS_export;
|
|
3
6
|
export default _default;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { usersApi } from "../../utils/api";
|
|
3
3
|
import { useLazyFetch, useLocaleLink, useModuleT, useRuntimeConfig } from "#imports";
|
|
4
4
|
defineOptions({ name: "UsersNewUsersStat" });
|
|
5
|
+
defineProps({
|
|
6
|
+
framed: { type: Boolean, required: false }
|
|
7
|
+
});
|
|
5
8
|
const t = useModuleT("users");
|
|
6
9
|
const { localize } = useLocaleLink();
|
|
7
10
|
const adminPage = useRuntimeConfig().public.users?.pages?.admin;
|
|
@@ -10,7 +13,7 @@ const { data: stats, status } = useLazyFetch(usersApi.admin.stats, { key: "admin
|
|
|
10
13
|
|
|
11
14
|
<template>
|
|
12
15
|
<StatCard
|
|
13
|
-
:label="t('admin.stats.newUsers', 'New users')"
|
|
16
|
+
:label="framed ? void 0 : t('admin.stats.newUsers', 'New users')"
|
|
14
17
|
icon="i-lucide-user-plus"
|
|
15
18
|
:value="stats?.newUsers"
|
|
16
19
|
:hint="stats ? t('admin.stats.ofTotal', '{total} users in total', { total: stats.total }) : void 0"
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
framed?: boolean;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
5
|
declare const _default: typeof __VLS_export;
|
|
3
6
|
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
user?: unknown;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { usersApi } from "../../utils/api";
|
|
4
|
+
import { useFormat, useLazyFetch, useLocaleLink, useModuleT } from "#imports";
|
|
5
|
+
defineOptions({ name: "UsersAccountTerms" });
|
|
6
|
+
defineProps({
|
|
7
|
+
user: { type: null, required: false }
|
|
8
|
+
});
|
|
9
|
+
const t = useModuleT("users");
|
|
10
|
+
const format = useFormat();
|
|
11
|
+
const { localize } = useLocaleLink();
|
|
12
|
+
const { data, status, error } = useLazyFetch(usersApi.me.terms, { key: "users:me:terms" });
|
|
13
|
+
const loading = computed(() => status.value === "pending" && !data.value);
|
|
14
|
+
const summary = computed(() => {
|
|
15
|
+
const accepted = data.value?.accepted;
|
|
16
|
+
if (!accepted) return t("terms.account.none", "You have not accepted the terms yet.");
|
|
17
|
+
return t("terms.account.accepted", "You accepted version {version} on {date}.", { version: accepted.version, date: format.dateTime(accepted.acceptedAt) });
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<SectionCard
|
|
23
|
+
:title="t('terms.account.title', 'Terms')"
|
|
24
|
+
:description="t('terms.account.description', 'The terms you accepted for using this site.')"
|
|
25
|
+
:loading="loading"
|
|
26
|
+
>
|
|
27
|
+
<UAlert
|
|
28
|
+
v-if="error"
|
|
29
|
+
color="error"
|
|
30
|
+
variant="subtle"
|
|
31
|
+
icon="i-lucide-circle-alert"
|
|
32
|
+
:title="t('terms.account.loadFailed', 'Your terms could not be loaded.')"
|
|
33
|
+
/>
|
|
34
|
+
<div
|
|
35
|
+
v-else-if="data"
|
|
36
|
+
class="flex flex-col gap-2 text-sm"
|
|
37
|
+
data-users-account-terms
|
|
38
|
+
>
|
|
39
|
+
<p class="text-highlighted">
|
|
40
|
+
{{ summary }}
|
|
41
|
+
</p>
|
|
42
|
+
<p
|
|
43
|
+
v-if="data.accepted && !data.upToDate"
|
|
44
|
+
class="text-muted"
|
|
45
|
+
>
|
|
46
|
+
{{ t("terms.account.outdated", "The terms have changed since (version {version}).", { version: data.current.version }) }}
|
|
47
|
+
</p>
|
|
48
|
+
</div>
|
|
49
|
+
<template #footer>
|
|
50
|
+
<div class="flex justify-end">
|
|
51
|
+
<UButton
|
|
52
|
+
color="neutral"
|
|
53
|
+
variant="outline"
|
|
54
|
+
icon="i-lucide-scroll-text"
|
|
55
|
+
:to="localize(data?.current.url ?? '')"
|
|
56
|
+
target="_blank"
|
|
57
|
+
:disabled="!data"
|
|
58
|
+
:label="t('terms.account.read', 'Read the terms')"
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
|
62
|
+
</SectionCard>
|
|
63
|
+
</template>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
user?: unknown;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** From the registration form: puts a value under the module's key of the request's `extras`. */
|
|
3
|
+
setExtra: (module: string, value: unknown) => void;
|
|
4
|
+
/** From the registration form: keeps it from being sent while `blocked`. Missing in older versions of auth. */
|
|
5
|
+
setBlocked?: (module: string, blocked: boolean) => void;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
|
3
|
+
import UsersTermsText from "../components/UsersTermsText.vue";
|
|
4
|
+
import { useNuxtApp, useRuntimeConfig } from "#imports";
|
|
5
|
+
defineOptions({ name: "UsersRegisterTerms" });
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
setExtra: { type: Function, required: true },
|
|
8
|
+
setBlocked: { type: Function, required: false }
|
|
9
|
+
});
|
|
10
|
+
const terms = useRuntimeConfig().public.users?.terms;
|
|
11
|
+
const i18n = useNuxtApp().$i18n;
|
|
12
|
+
const accepted = ref(false);
|
|
13
|
+
const locale = computed(() => i18n?.locale?.value);
|
|
14
|
+
watch([accepted, locale], ([value]) => {
|
|
15
|
+
if (!terms) return;
|
|
16
|
+
props.setExtra("users", value ? { termsVersion: terms.version, ...locale.value ? { locale: locale.value } : {} } : void 0);
|
|
17
|
+
props.setBlocked?.("users", !value);
|
|
18
|
+
}, { immediate: true });
|
|
19
|
+
onBeforeUnmount(() => {
|
|
20
|
+
props.setExtra("users", void 0);
|
|
21
|
+
props.setBlocked?.("users", false);
|
|
22
|
+
});
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<UCheckbox
|
|
27
|
+
v-if="terms"
|
|
28
|
+
v-model="accepted"
|
|
29
|
+
name="users-terms"
|
|
30
|
+
required
|
|
31
|
+
data-users-register-terms
|
|
32
|
+
>
|
|
33
|
+
<template #label>
|
|
34
|
+
<UsersTermsText :terms="terms" />
|
|
35
|
+
</template>
|
|
36
|
+
</UCheckbox>
|
|
37
|
+
</template>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** From the registration form: puts a value under the module's key of the request's `extras`. */
|
|
3
|
+
setExtra: (module: string, value: unknown) => void;
|
|
4
|
+
/** From the registration form: keeps it from being sent while `blocked`. Missing in older versions of auth. */
|
|
5
|
+
setBlocked?: (module: string, blocked: boolean) => void;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const users: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "users";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
acceptedTermsVersion: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "accepted_terms_version";
|
|
7
|
+
tableName: "users";
|
|
8
|
+
dataType: "string";
|
|
9
|
+
columnType: "PgText";
|
|
10
|
+
data: string;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: false;
|
|
13
|
+
hasDefault: false;
|
|
14
|
+
isPrimaryKey: false;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: [string, ...string[]];
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
};
|
|
23
|
+
dialect: "pg";
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const users: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
2
|
+
name: "users";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
acceptedTermsVersion: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
6
|
+
name: "accepted_terms_version";
|
|
7
|
+
tableName: "users";
|
|
8
|
+
dataType: "string";
|
|
9
|
+
columnType: "SQLiteText";
|
|
10
|
+
data: string;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: false;
|
|
13
|
+
hasDefault: false;
|
|
14
|
+
isPrimaryKey: false;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: [string, ...string[]];
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {
|
|
22
|
+
length: number | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
dialect: "sqlite";
|
|
26
|
+
}>;
|