@frigear-nu/users 3.1.4 → 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 +117 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +144 -27
- 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 +23 -5
- package/dist/runtime/app/pages/revert-email-change.vue +2 -1
- package/dist/runtime/app/plugins/offer-locale.client.js +22 -3
- 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 +88 -14
- 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/schema.postgresql.d.ts +68 -0
- package/dist/runtime/db/schema.postgresql.js +15 -4
- package/dist/runtime/db/schema.sqlite.d.ts +72 -0
- package/dist/runtime/db/schema.sqlite.js +15 -4
- 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 +85 -6
- package/dist/runtime/i18n/lang/en.json +85 -6
- 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 +14 -3
- package/dist/runtime/server/routes/admin/users.get.js +11 -3
- package/dist/runtime/server/routes/admin/users.post.js +1 -0
- 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 +23 -4
- 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 +12 -1
- package/dist/runtime/server/schemas.js +6 -1
- package/dist/runtime/server/search-index.js +2 -2
- package/dist/runtime/server/user-store.js +2 -1
- package/dist/runtime/server/utils/dto.d.ts +5 -1
- package/dist/runtime/server/utils/dto.js +8 -0
- package/dist/runtime/server/utils/user-refs.d.ts +2 -1
- package/dist/runtime/server/utils/user-refs.js +8 -2
- package/dist/runtime/server/utils/user-search.d.ts +13 -5
- package/dist/runtime/server/utils/user-search.js +13 -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 +25 -4
- package/dist/runtime/utils/api.js +23 -3
- package/dist/runtime/utils/avatar.d.ts +25 -0
- package/dist/runtime/utils/avatar.js +23 -0
- package/dist/runtime/utils/profile.d.ts +14 -0
- package/dist/runtime/utils/profile.js +8 -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
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { H3Event } from 'h3';
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Context of `users:deleted`: a staff member deleted the user (`DELETE /api/admin/users/:id`). Modules that keep rows
|
|
6
|
+
* about a user without a foreign key (wristbands, ...) remove them here. `event` is the request.
|
|
7
|
+
*/
|
|
8
|
+
type UserDeletedContext = {
|
|
9
|
+
event: H3Event;
|
|
10
|
+
userId: number;
|
|
11
|
+
};
|
|
3
12
|
type PublicModuleOptions = {
|
|
4
13
|
/** Where the page of the signed-in user's profile lives; the email change confirmation link lands there. */
|
|
5
14
|
profilePath?: string;
|
|
@@ -8,8 +17,49 @@ type PublicModuleOptions = {
|
|
|
8
17
|
pages: {
|
|
9
18
|
admin?: string;
|
|
10
19
|
};
|
|
20
|
+
/** The terms people accept (`users.terms`), or `undefined` when the host does not track them. */
|
|
21
|
+
terms?: UsersPublicTerms;
|
|
22
|
+
/** Whether users may upload a photo as their avatar (`avatarUpload`): the account page then offers it. */
|
|
23
|
+
avatarUpload: boolean;
|
|
24
|
+
/** The largest avatar upload in bytes (`maxAvatarBytes`). */
|
|
25
|
+
maxAvatarBytes: number;
|
|
26
|
+
};
|
|
27
|
+
/** The current terms, as the app sees them (`runtimeConfig.public.users.terms`). */
|
|
28
|
+
type UsersPublicTerms = {
|
|
29
|
+
/** The front matter `version` of the terms files. */
|
|
30
|
+
version: string;
|
|
31
|
+
/** Where the terms are read (a path of the site, localised by the app). */
|
|
32
|
+
url: string;
|
|
33
|
+
/** Where the privacy policy is read: linked next to the terms, not accepted. */
|
|
34
|
+
privacyUrl?: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Where an acceptance was given: the registration form, the prompt a signed-in user gets for new terms, or another app
|
|
38
|
+
* with the same terms, handed over at a frigear.nu login (the `terms` claim).
|
|
39
|
+
*/
|
|
40
|
+
type UsersTermsSource = 'sign-up' | 'prompt' | 'oauth';
|
|
41
|
+
/** The server's terms config (`runtimeConfig.users.terms`): the public part plus the hash of every locale's file. */
|
|
42
|
+
type UsersTermsRuntimeConfig = UsersPublicTerms & {
|
|
43
|
+
/** SHA-256 (hex) of each locale's terms file, in the order of `users.terms.files` (the first is the fallback). */
|
|
44
|
+
hashes: Record<string, string>;
|
|
45
|
+
};
|
|
46
|
+
/** Context of `users:terms:accepted`: a user accepted the current terms (a history row was written). */
|
|
47
|
+
type UsersTermsAcceptedContext = {
|
|
48
|
+
userId: number;
|
|
49
|
+
version: string;
|
|
50
|
+
/** Epoch milliseconds. */
|
|
51
|
+
acceptedAt: number;
|
|
52
|
+
source: UsersTermsSource;
|
|
11
53
|
};
|
|
12
54
|
type ModuleOptions = {
|
|
55
|
+
/**
|
|
56
|
+
* Users may upload a photo as their avatar (`PUT /api/users/me/avatar`). It is stored in NuxtHub Blob (the module
|
|
57
|
+
* turns `hub.blob` on) and served by the public `GET /api/users/avatars/:userId/:file`; `users.avatar` holds its
|
|
58
|
+
* absolute URL. Needs a blob binding (R2 on Cloudflare). Defaults to `false`: avatars are URLs only.
|
|
59
|
+
*/
|
|
60
|
+
avatarUpload?: boolean;
|
|
61
|
+
/** The largest avatar upload in bytes. Defaults to 2 MB. */
|
|
62
|
+
maxAvatarBytes?: number;
|
|
13
63
|
settings?: {
|
|
14
64
|
/**
|
|
15
65
|
* User administration for staff: list/create/edit users (`/api/admin/users`), a "new users" widget and an
|
|
@@ -32,15 +82,38 @@ type ModuleOptions = {
|
|
|
32
82
|
/** Expose the MCP tools of this module (`get-my-profile`) on the MCP endpoint. Needs `@frigear-nu/mcp`. Defaults to `false`. */
|
|
33
83
|
mcp?: boolean;
|
|
34
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* Terms people accept, with an append-only history of who accepted which version when (`user_terms_acceptances`) and
|
|
87
|
+
* the latest acceptance on the user (`acceptedTermsAt`, `acceptedTermsVersion`). Off unless set: no table, no
|
|
88
|
+
* registration checkbox, no prompt. The version is the front matter `version` of the files, read at build time with
|
|
89
|
+
* the SHA-256 of each file, so a stored hash proves which text was accepted. Signed-in users who have not accepted
|
|
90
|
+
* the current version are asked to before they go on.
|
|
91
|
+
*/
|
|
92
|
+
terms?: {
|
|
93
|
+
/** The page of the terms (a path of the site, localised by the app). */
|
|
94
|
+
url: string;
|
|
95
|
+
/** The page of the privacy policy, linked next to the terms (read, not accepted). */
|
|
96
|
+
privacyUrl?: string;
|
|
97
|
+
/** The terms file of each locale, relative to the app's root (`{ en: 'content/en/legal/terms.md' }`). The first is the fallback. */
|
|
98
|
+
files: Record<string, string>;
|
|
99
|
+
};
|
|
35
100
|
};
|
|
36
101
|
/** A user as the users admin API returns it (`GET /api/admin/users/:id`, create and edit): an allowlist, never the row. */
|
|
37
102
|
type AdminUserDto = {
|
|
38
103
|
id: number;
|
|
39
104
|
name: string;
|
|
105
|
+
/** What the user likes to be called; shown as "Name (nickname)". */
|
|
106
|
+
nickname: string | null;
|
|
40
107
|
email: string;
|
|
41
108
|
avatar: string | null;
|
|
42
109
|
/** Only in the detail and edit responses, and only for a caller with `users:pii`. */
|
|
43
110
|
phone?: string | null;
|
|
111
|
+
/** The person's id in an external system (not personal data: every staff member who sees the user sees it). */
|
|
112
|
+
peopleNumber: string | null;
|
|
113
|
+
/** The user asked not to be photographed as the main subject (crowd shots can still include them). */
|
|
114
|
+
photoOptOut: boolean;
|
|
115
|
+
/** The user asked not to be tagged in posts and photos online. */
|
|
116
|
+
tagOptOut: boolean;
|
|
44
117
|
emailVerifiedAt: string | null;
|
|
45
118
|
lastLoginAt: string | null;
|
|
46
119
|
createdAt: string;
|
|
@@ -49,14 +122,55 @@ type AdminUserDto = {
|
|
|
49
122
|
type ProfileDto = {
|
|
50
123
|
id: number;
|
|
51
124
|
name: string;
|
|
125
|
+
/** What the user likes to be called, or `null`. */
|
|
126
|
+
nickname: string | null;
|
|
52
127
|
email: string;
|
|
53
128
|
avatar: string | null;
|
|
54
129
|
phone: string | null;
|
|
130
|
+
/** The user's id in an external system (e.g. an event's volunteer system), or `null`. */
|
|
131
|
+
peopleNumber: string | null;
|
|
132
|
+
/** No photos with the user as the main subject. Crowd shots where they are not the focus can still include them. */
|
|
133
|
+
photoOptOut: boolean;
|
|
134
|
+
/** No tagging of the user in posts and photos online. */
|
|
135
|
+
tagOptOut: boolean;
|
|
55
136
|
/** The user's language (`da`, `en-GB`), or `null`. Filled from the app's language at sign-in when unset. */
|
|
56
137
|
locale: string | null;
|
|
57
138
|
emailVerifiedAt: string | null;
|
|
58
139
|
};
|
|
140
|
+
/** The signed-in user's terms (`GET /api/users/me/terms`): the current version and what they accepted last. */
|
|
141
|
+
type UserTermsStatusDto = {
|
|
142
|
+
current: UsersPublicTerms;
|
|
143
|
+
/** The latest acceptance, or `null` when the user never accepted any terms. */
|
|
144
|
+
accepted: {
|
|
145
|
+
version: string;
|
|
146
|
+
acceptedAt: string;
|
|
147
|
+
} | null;
|
|
148
|
+
/** Whether the latest acceptance is of the current version. */
|
|
149
|
+
upToDate: boolean;
|
|
150
|
+
};
|
|
151
|
+
/** One acceptance of a user's history (`GET /api/admin/users/:id/terms`, `users:pii`), newest first. */
|
|
152
|
+
type UserTermsAcceptanceDto = {
|
|
153
|
+
id: number;
|
|
154
|
+
version: string;
|
|
155
|
+
/** The locale of the text accepted. */
|
|
156
|
+
locale: string;
|
|
157
|
+
/** SHA-256 (hex) of the terms file accepted. */
|
|
158
|
+
contentHash: string;
|
|
159
|
+
acceptedAt: string;
|
|
160
|
+
source: UsersTermsSource;
|
|
161
|
+
/** A keyed hash (HMAC-SHA-256, hex) of the request's IP address, never the address; `null` without an address or key. */
|
|
162
|
+
ipHash: string | null;
|
|
163
|
+
userAgent: string | null;
|
|
164
|
+
};
|
|
59
165
|
|
|
166
|
+
declare module 'nitropack' {
|
|
167
|
+
interface NitroRuntimeHooks {
|
|
168
|
+
/** A user was deleted (after their row is gone): remove what you keep about them. */
|
|
169
|
+
'users:deleted': (ctx: UserDeletedContext) => void | Promise<void>;
|
|
170
|
+
/** A user accepted the current terms (`users.terms`), on the registration form or at the prompt; the history row is written. */
|
|
171
|
+
'users:terms:accepted': (ctx: UsersTermsAcceptedContext) => void | Promise<void>;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
60
174
|
declare module 'nuxt/schema' {
|
|
61
175
|
interface NuxtConfig {
|
|
62
176
|
users?: ModuleOptions;
|
|
@@ -66,6 +180,8 @@ declare module 'nuxt/schema' {
|
|
|
66
180
|
verifyEmailChange: boolean;
|
|
67
181
|
/** The app's i18n locale codes (filled at `modules:done`): the languages `users.locale` accepts. Empty: any short BCP-47 tag. */
|
|
68
182
|
locales: string[];
|
|
183
|
+
/** The terms (`users.terms`) with the hash of each locale's file, read at build time; `null` when off. */
|
|
184
|
+
terms: UsersTermsRuntimeConfig | null;
|
|
69
185
|
};
|
|
70
186
|
}
|
|
71
187
|
interface PublicRuntimeConfig {
|
|
@@ -75,4 +191,4 @@ declare module 'nuxt/schema' {
|
|
|
75
191
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
76
192
|
|
|
77
193
|
export { _default as default };
|
|
78
|
-
export type { AdminUserDto, ModuleOptions, ProfileDto, PublicModuleOptions };
|
|
194
|
+
export type { AdminUserDto, ModuleOptions, ProfileDto, PublicModuleOptions, UserDeletedContext, UserTermsAcceptanceDto, UserTermsStatusDto, UsersPublicTerms, UsersTermsAcceptedContext, UsersTermsSource };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,9 +1,49 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addComponent, addServerImportsDir, hasNuxtModule,
|
|
2
|
-
import { registerTailwindSource, registerLocales, registerDatabaseTable, registerSearchIndex, inlineModuleRuntime, addModulePages, addModuleRoutes, resolvePagePath, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
|
|
3
|
-
import { setAuthUserStore, registerAccess } from '@frigear-nu/auth/utils';
|
|
1
|
+
import { defineNuxtModule, createResolver, addComponent, addServerImportsDir, hasNuxtModule, addTypeTemplate, addNitroPlugin, addPlugin } from '@nuxt/kit';
|
|
2
|
+
import { registerTailwindSource, registerLocales, isClientOnlyApp, registerDatabaseTable, registerSearchIndex, inlineModuleRuntime, addModulePages, defineVirtualRegistry, extendDatabaseTable, addModuleRoutes, resolvePagePath, addOptionalMenuSource, serverModuleDependencies } from '@frigear-nu/module-kit/utils';
|
|
3
|
+
import { setAuthUserStore, AUTH_WIDGET_AREAS, registerAccess } from '@frigear-nu/auth/utils';
|
|
4
4
|
import { resolveAuthMode } from '@frigear-nu/auth/mode';
|
|
5
5
|
import { setNotifyRecipientStore } from '@frigear-nu/notify/utils';
|
|
6
6
|
import { usersAccess, USERS_SELF_SERVICE } from '../dist/runtime/access.js';
|
|
7
|
+
import { USERS_MAX_AVATAR_BYTES } from '../dist/runtime/utils/avatar.js';
|
|
8
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
|
|
12
|
+
function readTermsFrontMatterVersion(source) {
|
|
13
|
+
const match = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(source);
|
|
14
|
+
if (!match) return null;
|
|
15
|
+
for (const line of match[1].split(/\r?\n/)) {
|
|
16
|
+
const field = /^version\s*:(.*)$/.exec(line);
|
|
17
|
+
if (!field) continue;
|
|
18
|
+
const value = field[1].trim().replace(/^(['"])(.*)\1$/, "$2").trim();
|
|
19
|
+
return value || null;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function hashTermsSource(bytes) {
|
|
24
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
25
|
+
}
|
|
26
|
+
function readTermsFiles(rootDir, files) {
|
|
27
|
+
const entries = Object.entries(files);
|
|
28
|
+
if (!entries.length) throw new Error("[@frigear-nu/users] `users.terms.files` names no file: add one per locale (`{ en: 'content/en/terms.md' }`).");
|
|
29
|
+
const locales = {};
|
|
30
|
+
for (const [locale, file] of entries) {
|
|
31
|
+
const path = isAbsolute(file) ? file : resolve(rootDir, file);
|
|
32
|
+
let bytes;
|
|
33
|
+
try {
|
|
34
|
+
bytes = readFileSync(path);
|
|
35
|
+
} catch {
|
|
36
|
+
throw new Error(`[@frigear-nu/users] The terms file of \`${locale}\` (\`${file}\`) could not be read.`);
|
|
37
|
+
}
|
|
38
|
+
const version2 = readTermsFrontMatterVersion(bytes.toString("utf8"));
|
|
39
|
+
if (!version2) throw new Error(`[@frigear-nu/users] The terms file of \`${locale}\` (\`${file}\`) has no \`version\` in its front matter.`);
|
|
40
|
+
locales[locale] = { version: version2, hash: hashTermsSource(bytes) };
|
|
41
|
+
}
|
|
42
|
+
const [first] = entries;
|
|
43
|
+
const version = locales[first[0]].version;
|
|
44
|
+
const warnings = Object.entries(locales).filter(([, value]) => value.version !== version).map(([locale, value]) => `[@frigear-nu/users] The terms of \`${locale}\` are version \`${value.version}\`, the terms of \`${first[0]}\` \`${version}\`: \`${version}\` is the current version.`);
|
|
45
|
+
return { version, locales, warnings };
|
|
46
|
+
}
|
|
7
47
|
|
|
8
48
|
const module$1 = defineNuxtModule({
|
|
9
49
|
meta: { name: "@frigear-nu/users", configKey: "users" },
|
|
@@ -12,9 +52,8 @@ const module$1 = defineNuxtModule({
|
|
|
12
52
|
},
|
|
13
53
|
// `@frigear-nu/mcp` is only installed when `settings.mcp` is on.
|
|
14
54
|
moduleDependencies: (nuxt) => ({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
55
|
+
// Uploaded avatars are stored in NuxtHub Blob: it is turned on only with `avatarUpload`.
|
|
56
|
+
...serverModuleDependencies(nuxt, { "@nuxthub/core": nuxt.options.users?.avatarUpload === true ? { version: ">=0.10", defaults: { blob: true } } : { version: ">=0.0.1" } }),
|
|
18
57
|
"@frigear-nu/module-kit": {
|
|
19
58
|
version: ">=0.0.1"
|
|
20
59
|
},
|
|
@@ -39,7 +78,7 @@ const module$1 = defineNuxtModule({
|
|
|
39
78
|
version: ">=0.0.0",
|
|
40
79
|
optional: true
|
|
41
80
|
},
|
|
42
|
-
...nuxt.options.users?.settings?.mcp === true ? { "@frigear-nu/mcp": { version: ">=0.0.1" } } : {}
|
|
81
|
+
...nuxt.options.users?.settings?.mcp === true ? serverModuleDependencies(nuxt, { "@frigear-nu/mcp": { version: ">=0.0.1" } }) : {}
|
|
43
82
|
}),
|
|
44
83
|
async setup(options, nuxt) {
|
|
45
84
|
const resolver = createResolver(import.meta.url);
|
|
@@ -47,6 +86,7 @@ const module$1 = defineNuxtModule({
|
|
|
47
86
|
registerLocales(nuxt, resolver.resolve("./runtime/i18n/lang"));
|
|
48
87
|
const settings = options.settings ?? {};
|
|
49
88
|
const signInHere = resolveAuthMode(nuxt) !== "resource";
|
|
89
|
+
const server = !isClientOnlyApp(nuxt);
|
|
50
90
|
if (!signInHere && settings.verifyEmailChange) {
|
|
51
91
|
console.warn("[@frigear-nu/users] `settings.verifyEmailChange` does nothing with `authentication.mode: 'resource'`: the email address changes at the issuer.");
|
|
52
92
|
}
|
|
@@ -56,10 +96,12 @@ const module$1 = defineNuxtModule({
|
|
|
56
96
|
schema: (dialect) => `./runtime/db/schema.${dialect}`
|
|
57
97
|
});
|
|
58
98
|
registerSearchIndex(nuxt, { name: "users", handler: resolver.resolve("./runtime/server/search-index") });
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
99
|
+
if (server) {
|
|
100
|
+
setAuthUserStore(nuxt, resolver.resolve("./runtime/server/user-store"));
|
|
101
|
+
setNotifyRecipientStore(nuxt, resolver.resolve("./runtime/server/notify-recipients"));
|
|
102
|
+
nuxt.hook("notify:email:templates", (sources) => sources.push({ dir: resolver.resolve("./runtime/emails") }));
|
|
103
|
+
addServerImportsDir(resolver.resolve("./runtime/server/utils"));
|
|
104
|
+
}
|
|
63
105
|
inlineModuleRuntime(nuxt, resolver);
|
|
64
106
|
const selfRoutes = [
|
|
65
107
|
{ method: "patch", path: "me", file: "me/profile.patch" },
|
|
@@ -93,26 +135,89 @@ const module$1 = defineNuxtModule({
|
|
|
93
135
|
schema: (dialect) => `./runtime/db/email-changes.${dialect}`
|
|
94
136
|
});
|
|
95
137
|
}
|
|
96
|
-
|
|
97
|
-
if (
|
|
138
|
+
const avatarUpload = options.avatarUpload === true;
|
|
139
|
+
if (avatarUpload) {
|
|
140
|
+
selfRoutes.push(
|
|
141
|
+
{ method: "put", path: "me/avatar", file: "me/avatar.put" },
|
|
142
|
+
{ method: "delete", path: "me/avatar", file: "me/avatar.delete" },
|
|
143
|
+
{ method: "get", path: "avatars/:userId/:file", file: "avatar.get" }
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
defineVirtualRegistry(nuxt, {
|
|
147
|
+
filename: "#users/avatar-blob",
|
|
148
|
+
target: "server",
|
|
149
|
+
collect: () => avatarUpload && server,
|
|
150
|
+
contents: (enabled) => enabled ? `export { blob } from '@nuxthub/blob'
|
|
151
|
+
` : "export const blob = null\n"
|
|
152
|
+
});
|
|
153
|
+
addTypeTemplate({
|
|
154
|
+
filename: "types/users-avatar-blob.d.ts",
|
|
155
|
+
getContents: () => `declare module '#users/avatar-blob' {
|
|
156
|
+
export const blob: {
|
|
157
|
+
put(pathname: string, body: Uint8Array, options?: { contentType?: string, prefix?: string, addRandomSuffix?: boolean }): Promise<{ pathname: string }>
|
|
158
|
+
get(pathname: string): Promise<Blob | null>
|
|
159
|
+
del(pathnames: string | string[]): Promise<void>
|
|
160
|
+
list(options?: { prefix?: string, cursor?: string }): Promise<{ blobs: { pathname: string }[], hasMore: boolean, cursor?: string }>
|
|
161
|
+
} | null
|
|
162
|
+
}
|
|
163
|
+
`
|
|
164
|
+
}, { nitro: true, nuxt: true });
|
|
165
|
+
if (settings.mcp === true && server) {
|
|
98
166
|
const { addMcpDefinitions } = await import('@frigear-nu/mcp/utils');
|
|
99
167
|
addMcpDefinitions(nuxt, resolver.resolve("./runtime/server/mcp"));
|
|
100
168
|
}
|
|
101
|
-
|
|
169
|
+
let terms = null;
|
|
170
|
+
if (options.terms && (!server || !signInHere)) {
|
|
171
|
+
console.warn("[@frigear-nu/users] `users.terms` needs sessions on this server: it does nothing in a client-only app or with `authentication.mode: 'resource'`.");
|
|
172
|
+
} else if (options.terms) {
|
|
173
|
+
const files = readTermsFiles(nuxt.options.rootDir, options.terms.files);
|
|
174
|
+
for (const warning of files.warnings) console.warn(warning);
|
|
175
|
+
terms = {
|
|
176
|
+
version: files.version,
|
|
177
|
+
url: options.terms.url,
|
|
178
|
+
...options.terms.privacyUrl ? { privacyUrl: options.terms.privacyUrl } : {},
|
|
179
|
+
hashes: Object.fromEntries(Object.entries(files.locales).map(([locale, file]) => [locale, file.hash]))
|
|
180
|
+
};
|
|
181
|
+
nuxt.options.watch.push(...Object.values(options.terms.files).map((file) => resolve(nuxt.options.rootDir, file)));
|
|
182
|
+
registerDatabaseTable(nuxt, { resolver, schema: (dialect) => `./runtime/db/terms.${dialect}` });
|
|
183
|
+
extendDatabaseTable(nuxt, { resolver, file: (dialect) => `./runtime/db/terms-users.${dialect}` });
|
|
184
|
+
selfRoutes.push(
|
|
185
|
+
{ method: "get", path: "me/terms", file: "me/terms.get" },
|
|
186
|
+
{ method: "post", path: "me/terms", file: "me/terms.post" }
|
|
187
|
+
);
|
|
188
|
+
addNitroPlugin(resolver.resolve("./runtime/server/plugins/terms"));
|
|
189
|
+
if (hasNuxtModule("@frigear-nu/oauth-server", nuxt)) {
|
|
190
|
+
addNitroPlugin(resolver.resolve("./runtime/server/plugins/terms-claims"));
|
|
191
|
+
}
|
|
192
|
+
nuxt.hook("modules:done", () => {
|
|
193
|
+
if (hasNuxtModule("@nuxt/ui", nuxt) && hasNuxtModule("@frigear-nu/ui", nuxt)) {
|
|
194
|
+
addPlugin({ src: resolver.resolve("./runtime/app/plugins/terms-gate.client"), mode: "client" });
|
|
195
|
+
} else {
|
|
196
|
+
console.warn("[@frigear-nu/users] `users.terms` is on, but `@nuxt/ui` or `@frigear-nu/ui` is not installed: there is no prompt for new terms, check `GET /api/users/me/terms` yourself.");
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
if (hasNuxtModule("@frigear-nu/widget")) {
|
|
200
|
+
const { extendWidgets } = await import('@frigear-nu/widget/utils');
|
|
201
|
+
extendWidgets(nuxt, AUTH_WIDGET_AREAS.register, { id: "users-register-terms", component: resolver.resolve("./runtime/app/widgets/UsersRegisterTerms.vue"), order: 90 });
|
|
202
|
+
extendWidgets(nuxt, "account.profile", { id: "users-account-terms", component: resolver.resolve("./runtime/app/widgets/UsersAccountTerms.vue"), order: 50 });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
addModuleRoutes(resolver, selfRoutes, { base: "/api/users" });
|
|
206
|
+
nuxt.options.runtimeConfig.users = { verifyEmailChange: settings.verifyEmailChange === true, locales: [], terms };
|
|
102
207
|
nuxt.hook("modules:done", () => {
|
|
103
208
|
const locales = nuxt.options.i18n?.locales ?? [];
|
|
104
209
|
nuxt.options.runtimeConfig.users.locales = locales.map((locale) => typeof locale === "string" ? locale : locale.code);
|
|
105
210
|
if (hasNuxtModule("@nuxtjs/i18n", nuxt)) {
|
|
106
211
|
addPlugin({ src: resolver.resolve("./runtime/app/plugins/remember-locale.client"), mode: "client" });
|
|
107
|
-
if (hasNuxtModule("@nuxt/ui", nuxt)) {
|
|
212
|
+
if (hasNuxtModule("@nuxt/ui", nuxt) && resolveAuthMode(nuxt) !== "client") {
|
|
108
213
|
addPlugin({ src: resolver.resolve("./runtime/app/plugins/offer-locale.client"), mode: "client" });
|
|
109
214
|
}
|
|
110
215
|
}
|
|
111
|
-
if (hasNuxtModule("@frigear-nu/oauth-server", nuxt)) {
|
|
216
|
+
if (server && hasNuxtModule("@frigear-nu/oauth-server", nuxt)) {
|
|
112
217
|
addNitroPlugin(resolver.resolve("./runtime/server/plugins/oauth-claims"));
|
|
113
218
|
}
|
|
114
219
|
});
|
|
115
|
-
addNitroPlugin(resolver.resolve("./runtime/server/plugins/frigear-locale"));
|
|
220
|
+
if (server) addNitroPlugin(resolver.resolve("./runtime/server/plugins/frigear-locale"));
|
|
116
221
|
const withAdmin = !!settings.admin;
|
|
117
222
|
registerAccess(nuxt, usersAccess, withAdmin ? {} : { permissions: USERS_SELF_SERVICE });
|
|
118
223
|
const adminOptions = typeof settings.admin === "object" ? settings.admin : {};
|
|
@@ -130,7 +235,10 @@ const module$1 = defineNuxtModule({
|
|
|
130
235
|
{ method: "get", path: ":id", file: "admin/user.get" },
|
|
131
236
|
{ method: "patch", path: ":id", file: "admin/user.patch" },
|
|
132
237
|
{ method: "delete", path: ":id", file: "admin/user.delete" },
|
|
133
|
-
|
|
238
|
+
{ method: "delete", path: ":id/avatar", file: "admin/user-avatar.delete" },
|
|
239
|
+
...signInHere ? [{ method: "post", path: ":id/resend", file: "admin/user-resend.post" }] : [],
|
|
240
|
+
// The terms history (`users:pii`), with `users.terms`.
|
|
241
|
+
...terms ? [{ method: "get", path: ":id/terms", file: "admin/user-terms.get" }] : []
|
|
134
242
|
], { base: "/api/admin/users" });
|
|
135
243
|
if (adminPagePath) {
|
|
136
244
|
addModulePages("@frigear-nu/users", resolver, [
|
|
@@ -139,7 +247,7 @@ const module$1 = defineNuxtModule({
|
|
|
139
247
|
]);
|
|
140
248
|
}
|
|
141
249
|
if (withAdminShell && hasNuxtModule("@frigear-nu/widget")) {
|
|
142
|
-
const {
|
|
250
|
+
const { extendTabs } = await import('@frigear-nu/widget/utils');
|
|
143
251
|
extendTabs(nuxt, "admin.users", {
|
|
144
252
|
id: "overview",
|
|
145
253
|
component: resolver.resolve("./runtime/app/tabs/Overview.vue"),
|
|
@@ -148,16 +256,22 @@ const module$1 = defineNuxtModule({
|
|
|
148
256
|
labelKey: "users.admin.tabs.overview",
|
|
149
257
|
icon: "i-lucide-user"
|
|
150
258
|
});
|
|
151
|
-
|
|
259
|
+
const { extendAdminDashboard } = await import('@frigear-nu/admin/utils');
|
|
260
|
+
extendAdminDashboard(nuxt, {
|
|
261
|
+
id: "users-new-users-stat",
|
|
262
|
+
component: resolver.resolve("./runtime/app/widgets/NewUsersStat.vue"),
|
|
263
|
+
title: "New users",
|
|
264
|
+
titleKey: "users.admin.dashboard.newUsersStat",
|
|
265
|
+
order: 10,
|
|
266
|
+
size: { cols: 1, maxCols: 2 }
|
|
267
|
+
}, "top");
|
|
268
|
+
extendAdminDashboard(nuxt, {
|
|
152
269
|
id: "users-new-users",
|
|
153
270
|
component: resolver.resolve("./runtime/app/widgets/NewUsers.vue"),
|
|
271
|
+
title: "Latest sign-ups",
|
|
272
|
+
titleKey: "users.admin.dashboard.newUsers",
|
|
154
273
|
order: 20,
|
|
155
|
-
|
|
156
|
-
});
|
|
157
|
-
extendWidgets(nuxt, "admin.dashboard.top", {
|
|
158
|
-
id: "users-new-users-stat",
|
|
159
|
-
component: resolver.resolve("./runtime/app/widgets/NewUsersStat.vue"),
|
|
160
|
-
order: 10
|
|
274
|
+
size: { cols: 2, minCols: 1, maxCols: 4, rows: 2 }
|
|
161
275
|
});
|
|
162
276
|
}
|
|
163
277
|
}
|
|
@@ -167,7 +281,10 @@ const module$1 = defineNuxtModule({
|
|
|
167
281
|
nuxt.options.runtimeConfig.public.users = {
|
|
168
282
|
profilePath: settings.profilePath,
|
|
169
283
|
mcp: settings.mcp === true,
|
|
170
|
-
pages: { admin: adminPagePath }
|
|
284
|
+
pages: { admin: adminPagePath },
|
|
285
|
+
...terms ? { terms: { version: terms.version, url: terms.url, ...terms.privacyUrl ? { privacyUrl: terms.privacyUrl } : {} } } : {},
|
|
286
|
+
avatarUpload,
|
|
287
|
+
maxAvatarBytes: options.maxAvatarBytes ?? USERS_MAX_AVATAR_BYTES
|
|
171
288
|
};
|
|
172
289
|
}
|
|
173
290
|
});
|
package/dist/runtime/access.js
CHANGED
|
@@ -6,8 +6,8 @@ export const usersAccess = defineAccess("users", {
|
|
|
6
6
|
// email address and password are not part of it: they change only in a session
|
|
7
7
|
// (`requireUser(event, { sessionOnly: true })`); staff change another user's email with the session-only
|
|
8
8
|
// `users:manage`.
|
|
9
|
-
"profile:read": { label: "Read your profile", description: "Read your own name, email, avatar and
|
|
10
|
-
"profile:write": { label: "Change your profile", description: "Change your own name, avatar and
|
|
9
|
+
"profile:read": { label: "Read your profile", description: "Read your own name, email, avatar, phone number and other profile details.", implicit: true },
|
|
10
|
+
"profile:write": { label: "Change your profile", description: "Change your own name, nickname, avatar, phone number, people number and photo choices.", implicit: true },
|
|
11
11
|
// Staff permissions (with the admin pages only), granted through roles (`admin: ['*']` covers them). Reads also work
|
|
12
12
|
// for API tokens and OAuth access tokens given them. Deleting a user and anything that touches how someone signs in
|
|
13
13
|
// (their email, sign-in links) is session only. Roles themselves are `@frigear-nu/authorization`'s.
|
|
@@ -16,7 +16,7 @@ export const usersAccess = defineAccess("users", {
|
|
|
16
16
|
// Granted to `admin` by name; give it to other staff roles in the host's `authorization.roles`. It covers an optional
|
|
17
17
|
// phone number on the new user (changing it later is `users:pii`).
|
|
18
18
|
"create": { label: "Add users", description: "Create users and email them an invite link.", grantTo: ["admin"] },
|
|
19
|
-
"update": { label: "Edit users", description: "Change a user's name." },
|
|
19
|
+
"update": { label: "Edit users", description: "Change a user's name, nickname and people number." },
|
|
20
20
|
"delete": { label: "Delete users", description: "Delete users and their sign-in methods.", sessionOnly: true },
|
|
21
21
|
"manage": { label: "Manage sign-in of users", description: "Change or verify a user's email address and email them a sign-in link.", sessionOnly: true },
|
|
22
22
|
// Sensitive (`:pii`): never covered by `users:*` or `*`, only granted by name. Other modules show the phone number
|
|
@@ -1,6 +1,7 @@
|
|
|
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 { z } from "zod";
|
|
5
6
|
import { $fetch, reactive, ref, useErrorToast, useModuleT, useNuxtApp, useToast } from "#imports";
|
|
6
7
|
defineOptions({ name: "UsersUserCreateSlideover" });
|
|
@@ -18,7 +19,9 @@ const locale = useNuxtApp().$i18n?.locale?.value || void 0;
|
|
|
18
19
|
const schema = z.object({
|
|
19
20
|
name: z.string().trim().min(1, t("admin.nameRequired", "Enter a name.")).max(120),
|
|
20
21
|
email: z.string().trim().email(t("admin.emailInvalid", "Enter a valid email address.")),
|
|
21
|
-
|
|
22
|
+
// The server's rule and a full international number (`PhoneInput` writes `+4512345678`); a prefilled number passes
|
|
23
|
+
// as given, since the server accepts it.
|
|
24
|
+
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.initial?.phone ?? "") || !phoneIssue(value), t("admin.phoneInvalid", "Enter a valid phone number.")),
|
|
22
25
|
emailVerified: z.boolean(),
|
|
23
26
|
sendWelcomeEmail: z.boolean()
|
|
24
27
|
});
|
|
@@ -103,11 +106,10 @@ const chooseExisting = () => {
|
|
|
103
106
|
:label="t('admin.phone', 'Phone')"
|
|
104
107
|
:description="t('admin.createPhoneHelp', 'Optional. Used for text messages.')"
|
|
105
108
|
>
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
class="w-full"
|
|
109
|
+
<PhoneInput
|
|
110
|
+
:model-value="state.phone"
|
|
111
|
+
:country-label="t('admin.phoneCountry', 'Country')"
|
|
112
|
+
@update:model-value="state.phone = $event ?? ''"
|
|
111
113
|
/>
|
|
112
114
|
</UFormField>
|
|
113
115
|
<UCheckbox
|
|
@@ -32,12 +32,12 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
32
32
|
canCreate: import("vue").ComputedRef<boolean>;
|
|
33
33
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
34
34
|
created: (user: UserPickerOption) => any;
|
|
35
|
-
picked: (user: UserPickerOption) => any;
|
|
36
35
|
"update:modelValue": (value: number | number[] | null | undefined) => any;
|
|
36
|
+
picked: (user: UserPickerOption) => any;
|
|
37
37
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
38
38
|
onCreated?: ((user: UserPickerOption) => any) | undefined;
|
|
39
|
-
onPicked?: ((user: UserPickerOption) => any) | undefined;
|
|
40
39
|
"onUpdate:modelValue"?: ((value: number | number[] | null | undefined) => any) | undefined;
|
|
40
|
+
onPicked?: ((user: UserPickerOption) => any) | undefined;
|
|
41
41
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
42
42
|
declare const _default: typeof __VLS_export;
|
|
43
43
|
export default _default;
|
|
@@ -32,12 +32,12 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
32
32
|
canCreate: import("vue").ComputedRef<boolean>;
|
|
33
33
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
34
34
|
created: (user: UserPickerOption) => any;
|
|
35
|
-
picked: (user: UserPickerOption) => any;
|
|
36
35
|
"update:modelValue": (value: number | number[] | null | undefined) => any;
|
|
36
|
+
picked: (user: UserPickerOption) => any;
|
|
37
37
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
38
38
|
onCreated?: ((user: UserPickerOption) => any) | undefined;
|
|
39
|
-
onPicked?: ((user: UserPickerOption) => any) | undefined;
|
|
40
39
|
"onUpdate:modelValue"?: ((value: number | number[] | null | undefined) => any) | undefined;
|
|
40
|
+
onPicked?: ((user: UserPickerOption) => any) | undefined;
|
|
41
41
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
42
42
|
declare const _default: typeof __VLS_export;
|
|
43
43
|
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
userId: number;
|
|
3
|
+
currentVersion: string;
|
|
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;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { usersApi } from "../../utils/api";
|
|
4
|
+
import { tableUi, useFormat, useLazyFetch, useModuleT } from "#imports";
|
|
5
|
+
defineOptions({ name: "UsersAdminTerms" });
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
userId: { type: Number, required: true },
|
|
8
|
+
currentVersion: { type: String, required: true }
|
|
9
|
+
});
|
|
10
|
+
const t = useModuleT("users");
|
|
11
|
+
const format = useFormat();
|
|
12
|
+
const { data, status, error } = useLazyFetch(() => usersApi.admin.terms(props.userId), {
|
|
13
|
+
key: `users:admin:terms:${props.userId}`,
|
|
14
|
+
default: () => []
|
|
15
|
+
});
|
|
16
|
+
const loading = computed(() => status.value === "pending" && !data.value?.length);
|
|
17
|
+
const latest = computed(() => data.value?.[0]);
|
|
18
|
+
const summary = computed(() => {
|
|
19
|
+
if (error.value) return t("admin.terms.loadFailed", "The terms history could not be loaded.");
|
|
20
|
+
if (!latest.value) return t("admin.terms.none", "Has not accepted any terms.");
|
|
21
|
+
const text = t("admin.terms.latest", "Version {version}, accepted {date}.", { version: latest.value.version, date: format.dateTime(latest.value.acceptedAt) });
|
|
22
|
+
return latest.value.version === props.currentVersion ? text : `${text} ${t("admin.terms.outdated", "Not the current version ({version}).", { version: props.currentVersion })}`;
|
|
23
|
+
});
|
|
24
|
+
const sourceLabel = (source) => source === "sign-up" ? t("admin.terms.sources.signUp", "Sign-up") : source === "oauth" ? t("admin.terms.sources.oauth", "Another app (login)") : t("admin.terms.sources.prompt", "Signed in");
|
|
25
|
+
const columns = computed(() => [
|
|
26
|
+
{ accessorKey: "version", header: t("admin.terms.version", "Version") },
|
|
27
|
+
{ accessorKey: "acceptedAt", header: t("admin.terms.acceptedAt", "Accepted"), cell: ({ row }) => format.dateTime(row.original.acceptedAt) },
|
|
28
|
+
{ accessorKey: "source", header: t("admin.terms.source", "Where"), cell: ({ row }) => sourceLabel(row.original.source) },
|
|
29
|
+
{ accessorKey: "locale", header: t("admin.terms.locale", "Language") },
|
|
30
|
+
{ accessorKey: "contentHash", header: t("admin.terms.hash", "Text hash"), cell: ({ row }) => row.original.contentHash.slice(0, 12) }
|
|
31
|
+
]);
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<TableCard
|
|
36
|
+
:title="t('admin.terms.title', 'Terms')"
|
|
37
|
+
:description="summary"
|
|
38
|
+
:loading="loading"
|
|
39
|
+
>
|
|
40
|
+
<UTable
|
|
41
|
+
:data="data ?? []"
|
|
42
|
+
:columns="columns"
|
|
43
|
+
:ui="tableUi({ tr: '' })"
|
|
44
|
+
>
|
|
45
|
+
<template #empty>
|
|
46
|
+
<UEmpty
|
|
47
|
+
icon="i-lucide-scroll-text"
|
|
48
|
+
variant="naked"
|
|
49
|
+
:title="t('admin.terms.empty', 'No acceptances yet')"
|
|
50
|
+
:description="t('admin.terms.emptyHint', 'The user is asked to accept the terms when they next sign in.')"
|
|
51
|
+
/>
|
|
52
|
+
</template>
|
|
53
|
+
</UTable>
|
|
54
|
+
</TableCard>
|
|
55
|
+
</template>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
userId: number;
|
|
3
|
+
currentVersion: string;
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UserTermsStatusDto } from '../../../types.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
status: UserTermsStatusDto;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
close: (args_0: UserTermsStatusDto | null) => any;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
|
+
onClose?: ((args_0: UserTermsStatusDto | null) => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|