@frigear-nu/users 3.1.5 → 3.2.0
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 +118 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +136 -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 +70 -2
- 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 +70 -0
- package/dist/runtime/app/tabs/Overview.vue +24 -13
- package/dist/runtime/app/utils/admin-user.d.ts +9 -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 +43 -28
- 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 +24 -3
- 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 +75 -5
- package/dist/runtime/i18n/lang/en.json +75 -5
- 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/stats.get.js +9 -5
- 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 +7 -40
- 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/admin-list.d.ts +45 -0
- package/dist/runtime/server/utils/admin-list.js +54 -0
- package/dist/runtime/server/utils/admin.d.ts +2 -0
- package/dist/runtime/server/utils/admin.js +1 -0
- 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 +22 -3
- package/dist/runtime/utils/api.js +21 -2
- 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/runtime/utils/trend.d.ts +9 -0
- package/dist/runtime/utils/trend.js +5 -0
- package/dist/types.d.mts +1 -1
- package/package.json +18 -13
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { H3Event } from 'h3';
|
|
3
|
+
import { SQL } from 'drizzle-orm';
|
|
2
4
|
|
|
5
|
+
type UsersMembershipFilterContext = {
|
|
6
|
+
event: H3Event;
|
|
7
|
+
now: Date;
|
|
8
|
+
status?: 'active' | 'expired' | 'none';
|
|
9
|
+
plan?: string;
|
|
10
|
+
condition?: SQL;
|
|
11
|
+
plans: {
|
|
12
|
+
value: string;
|
|
13
|
+
label: string;
|
|
14
|
+
}[];
|
|
15
|
+
exportUrl?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Context of `users:deleted`: a staff member deleted the user (`DELETE /api/admin/users/:id`). Modules that keep rows
|
|
19
|
+
* about a user without a foreign key (wristbands, ...) remove them here. `event` is the request.
|
|
20
|
+
*/
|
|
21
|
+
type UserDeletedContext = {
|
|
22
|
+
event: H3Event;
|
|
23
|
+
userId: number;
|
|
24
|
+
};
|
|
3
25
|
type PublicModuleOptions = {
|
|
4
26
|
/** Where the page of the signed-in user's profile lives; the email change confirmation link lands there. */
|
|
5
27
|
profilePath?: string;
|
|
@@ -8,8 +30,49 @@ type PublicModuleOptions = {
|
|
|
8
30
|
pages: {
|
|
9
31
|
admin?: string;
|
|
10
32
|
};
|
|
33
|
+
/** The terms people accept (`users.terms`), or `undefined` when the host does not track them. */
|
|
34
|
+
terms?: UsersPublicTerms;
|
|
35
|
+
/** Whether users may upload a photo as their avatar (`avatarUpload`): the account page then offers it. */
|
|
36
|
+
avatarUpload: boolean;
|
|
37
|
+
/** The largest avatar upload in bytes (`maxAvatarBytes`). */
|
|
38
|
+
maxAvatarBytes: number;
|
|
39
|
+
};
|
|
40
|
+
/** The current terms, as the app sees them (`runtimeConfig.public.users.terms`). */
|
|
41
|
+
type UsersPublicTerms = {
|
|
42
|
+
/** The front matter `version` of the terms files. */
|
|
43
|
+
version: string;
|
|
44
|
+
/** Where the terms are read (a path of the site, localised by the app). */
|
|
45
|
+
url: string;
|
|
46
|
+
/** Where the privacy policy is read: linked next to the terms, not accepted. */
|
|
47
|
+
privacyUrl?: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Where an acceptance was given: the registration form, the prompt a signed-in user gets for new terms, or another app
|
|
51
|
+
* with the same terms, handed over at a frigear.nu login (the `terms` claim).
|
|
52
|
+
*/
|
|
53
|
+
type UsersTermsSource = 'sign-up' | 'prompt' | 'oauth';
|
|
54
|
+
/** The server's terms config (`runtimeConfig.users.terms`): the public part plus the hash of every locale's file. */
|
|
55
|
+
type UsersTermsRuntimeConfig = UsersPublicTerms & {
|
|
56
|
+
/** SHA-256 (hex) of each locale's terms file, in the order of `users.terms.files` (the first is the fallback). */
|
|
57
|
+
hashes: Record<string, string>;
|
|
58
|
+
};
|
|
59
|
+
/** Context of `users:terms:accepted`: a user accepted the current terms (a history row was written). */
|
|
60
|
+
type UsersTermsAcceptedContext = {
|
|
61
|
+
userId: number;
|
|
62
|
+
version: string;
|
|
63
|
+
/** Epoch milliseconds. */
|
|
64
|
+
acceptedAt: number;
|
|
65
|
+
source: UsersTermsSource;
|
|
11
66
|
};
|
|
12
67
|
type ModuleOptions = {
|
|
68
|
+
/**
|
|
69
|
+
* Users may upload a photo as their avatar (`PUT /api/users/me/avatar`). It is stored in NuxtHub Blob (the module
|
|
70
|
+
* turns `hub.blob` on) and served by the public `GET /api/users/avatars/:userId/:file`; `users.avatar` holds its
|
|
71
|
+
* absolute URL. Needs a blob binding (R2 on Cloudflare). Defaults to `false`: avatars are URLs only.
|
|
72
|
+
*/
|
|
73
|
+
avatarUpload?: boolean;
|
|
74
|
+
/** The largest avatar upload in bytes. Defaults to 2 MB. */
|
|
75
|
+
maxAvatarBytes?: number;
|
|
13
76
|
settings?: {
|
|
14
77
|
/**
|
|
15
78
|
* User administration for staff: list/create/edit users (`/api/admin/users`), a "new users" widget and an
|
|
@@ -32,6 +95,21 @@ type ModuleOptions = {
|
|
|
32
95
|
/** Expose the MCP tools of this module (`get-my-profile`) on the MCP endpoint. Needs `@frigear-nu/mcp`. Defaults to `false`. */
|
|
33
96
|
mcp?: boolean;
|
|
34
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* Terms people accept, with an append-only history of who accepted which version when (`user_terms_acceptances`) and
|
|
100
|
+
* the latest acceptance on the user (`acceptedTermsAt`, `acceptedTermsVersion`). Off unless set: no table, no
|
|
101
|
+
* registration checkbox, no prompt. The version is the front matter `version` of the files, read at build time with
|
|
102
|
+
* the SHA-256 of each file, so a stored hash proves which text was accepted. Signed-in users who have not accepted
|
|
103
|
+
* the current version are asked to before they go on.
|
|
104
|
+
*/
|
|
105
|
+
terms?: {
|
|
106
|
+
/** The page of the terms (a path of the site, localised by the app). */
|
|
107
|
+
url: string;
|
|
108
|
+
/** The page of the privacy policy, linked next to the terms (read, not accepted). */
|
|
109
|
+
privacyUrl?: string;
|
|
110
|
+
/** The terms file of each locale, relative to the app's root (`{ en: 'content/en/legal/terms.md' }`). The first is the fallback. */
|
|
111
|
+
files: Record<string, string>;
|
|
112
|
+
};
|
|
35
113
|
};
|
|
36
114
|
/** A user as the users admin API returns it (`GET /api/admin/users/:id`, create and edit): an allowlist, never the row. */
|
|
37
115
|
type AdminUserDto = {
|
|
@@ -43,8 +121,8 @@ type AdminUserDto = {
|
|
|
43
121
|
avatar: string | null;
|
|
44
122
|
/** Only in the detail and edit responses, and only for a caller with `users:pii`. */
|
|
45
123
|
phone?: string | null;
|
|
46
|
-
/** The person's id in an external system
|
|
47
|
-
peopleNumber
|
|
124
|
+
/** The person's id in an external system (not personal data: every staff member who sees the user sees it). */
|
|
125
|
+
peopleNumber: string | null;
|
|
48
126
|
/** The user asked not to be photographed as the main subject (crowd shots can still include them). */
|
|
49
127
|
photoOptOut: boolean;
|
|
50
128
|
/** The user asked not to be tagged in posts and photos online. */
|
|
@@ -72,7 +150,42 @@ type ProfileDto = {
|
|
|
72
150
|
locale: string | null;
|
|
73
151
|
emailVerifiedAt: string | null;
|
|
74
152
|
};
|
|
153
|
+
/** The signed-in user's terms (`GET /api/users/me/terms`): the current version and what they accepted last. */
|
|
154
|
+
type UserTermsStatusDto = {
|
|
155
|
+
current: UsersPublicTerms;
|
|
156
|
+
/** The latest acceptance, or `null` when the user never accepted any terms. */
|
|
157
|
+
accepted: {
|
|
158
|
+
version: string;
|
|
159
|
+
acceptedAt: string;
|
|
160
|
+
} | null;
|
|
161
|
+
/** Whether the latest acceptance is of the current version. */
|
|
162
|
+
upToDate: boolean;
|
|
163
|
+
};
|
|
164
|
+
/** One acceptance of a user's history (`GET /api/admin/users/:id/terms`, `users:pii`), newest first. */
|
|
165
|
+
type UserTermsAcceptanceDto = {
|
|
166
|
+
id: number;
|
|
167
|
+
version: string;
|
|
168
|
+
/** The locale of the text accepted. */
|
|
169
|
+
locale: string;
|
|
170
|
+
/** SHA-256 (hex) of the terms file accepted. */
|
|
171
|
+
contentHash: string;
|
|
172
|
+
acceptedAt: string;
|
|
173
|
+
source: UsersTermsSource;
|
|
174
|
+
/** A keyed hash (HMAC-SHA-256, hex) of the request's IP address, never the address; `null` without an address or key. */
|
|
175
|
+
ipHash: string | null;
|
|
176
|
+
userAgent: string | null;
|
|
177
|
+
};
|
|
75
178
|
|
|
179
|
+
declare module 'nitropack' {
|
|
180
|
+
interface NitroRuntimeHooks {
|
|
181
|
+
/** Supplies the optional membership filters for the admin users list. */
|
|
182
|
+
'users:admin:membership-filter': (ctx: UsersMembershipFilterContext) => void | Promise<void>;
|
|
183
|
+
/** A user was deleted (after their row is gone): remove what you keep about them. */
|
|
184
|
+
'users:deleted': (ctx: UserDeletedContext) => void | Promise<void>;
|
|
185
|
+
/** A user accepted the current terms (`users.terms`), on the registration form or at the prompt; the history row is written. */
|
|
186
|
+
'users:terms:accepted': (ctx: UsersTermsAcceptedContext) => void | Promise<void>;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
76
189
|
declare module 'nuxt/schema' {
|
|
77
190
|
interface NuxtConfig {
|
|
78
191
|
users?: ModuleOptions;
|
|
@@ -82,6 +195,8 @@ declare module 'nuxt/schema' {
|
|
|
82
195
|
verifyEmailChange: boolean;
|
|
83
196
|
/** The app's i18n locale codes (filled at `modules:done`): the languages `users.locale` accepts. Empty: any short BCP-47 tag. */
|
|
84
197
|
locales: string[];
|
|
198
|
+
/** The terms (`users.terms`) with the hash of each locale's file, read at build time; `null` when off. */
|
|
199
|
+
terms: UsersTermsRuntimeConfig | null;
|
|
85
200
|
};
|
|
86
201
|
}
|
|
87
202
|
interface PublicRuntimeConfig {
|
|
@@ -91,4 +206,4 @@ declare module 'nuxt/schema' {
|
|
|
91
206
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
92
207
|
|
|
93
208
|
export { _default as default };
|
|
94
|
-
export type { AdminUserDto, ModuleOptions, ProfileDto, PublicModuleOptions };
|
|
209
|
+
export type { AdminUserDto, ModuleOptions, ProfileDto, PublicModuleOptions, UserDeletedContext, UserTermsAcceptanceDto, UserTermsStatusDto, UsersMembershipFilterContext, 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, isClientOnlyApp, registerDatabaseTable, registerSearchIndex, inlineModuleRuntime, addModulePages, addModuleRoutes, resolvePagePath, addOptionalMenuSource, serverModuleDependencies } 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,7 +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
|
-
|
|
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" } }),
|
|
16
57
|
"@frigear-nu/module-kit": {
|
|
17
58
|
version: ">=0.0.1"
|
|
18
59
|
},
|
|
@@ -94,12 +135,75 @@ const module$1 = defineNuxtModule({
|
|
|
94
135
|
schema: (dialect) => `./runtime/db/email-changes.${dialect}`
|
|
95
136
|
});
|
|
96
137
|
}
|
|
97
|
-
|
|
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 });
|
|
98
165
|
if (settings.mcp === true && server) {
|
|
99
166
|
const { addMcpDefinitions } = await import('@frigear-nu/mcp/utils');
|
|
100
167
|
addMcpDefinitions(nuxt, resolver.resolve("./runtime/server/mcp"));
|
|
101
168
|
}
|
|
102
|
-
|
|
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 };
|
|
103
207
|
nuxt.hook("modules:done", () => {
|
|
104
208
|
const locales = nuxt.options.i18n?.locales ?? [];
|
|
105
209
|
nuxt.options.runtimeConfig.users.locales = locales.map((locale) => typeof locale === "string" ? locale : locale.code);
|
|
@@ -131,7 +235,10 @@ const module$1 = defineNuxtModule({
|
|
|
131
235
|
{ method: "get", path: ":id", file: "admin/user.get" },
|
|
132
236
|
{ method: "patch", path: ":id", file: "admin/user.patch" },
|
|
133
237
|
{ method: "delete", path: ":id", file: "admin/user.delete" },
|
|
134
|
-
|
|
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" }] : []
|
|
135
242
|
], { base: "/api/admin/users" });
|
|
136
243
|
if (adminPagePath) {
|
|
137
244
|
addModulePages("@frigear-nu/users", resolver, [
|
|
@@ -140,7 +247,7 @@ const module$1 = defineNuxtModule({
|
|
|
140
247
|
]);
|
|
141
248
|
}
|
|
142
249
|
if (withAdminShell && hasNuxtModule("@frigear-nu/widget")) {
|
|
143
|
-
const {
|
|
250
|
+
const { extendTabs } = await import('@frigear-nu/widget/utils');
|
|
144
251
|
extendTabs(nuxt, "admin.users", {
|
|
145
252
|
id: "overview",
|
|
146
253
|
component: resolver.resolve("./runtime/app/tabs/Overview.vue"),
|
|
@@ -149,16 +256,26 @@ const module$1 = defineNuxtModule({
|
|
|
149
256
|
labelKey: "users.admin.tabs.overview",
|
|
150
257
|
icon: "i-lucide-user"
|
|
151
258
|
});
|
|
152
|
-
|
|
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
|
+
// Shown to staff who may read the numbers (the route checks it too).
|
|
268
|
+
permission: usersAccess.permissions.list
|
|
269
|
+
}, "top");
|
|
270
|
+
extendAdminDashboard(nuxt, {
|
|
153
271
|
id: "users-new-users",
|
|
154
272
|
component: resolver.resolve("./runtime/app/widgets/NewUsers.vue"),
|
|
273
|
+
title: "Latest sign-ups",
|
|
274
|
+
icon: "i-lucide-users",
|
|
275
|
+
titleKey: "users.admin.dashboard.newUsers",
|
|
155
276
|
order: 20,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
extendWidgets(nuxt, "admin.dashboard.top", {
|
|
159
|
-
id: "users-new-users-stat",
|
|
160
|
-
component: resolver.resolve("./runtime/app/widgets/NewUsersStat.vue"),
|
|
161
|
-
order: 10
|
|
277
|
+
size: { cols: 2, minCols: 1, maxCols: 4, rows: 2 },
|
|
278
|
+
permission: usersAccess.permissions.list
|
|
162
279
|
});
|
|
163
280
|
}
|
|
164
281
|
}
|
|
@@ -168,7 +285,10 @@ const module$1 = defineNuxtModule({
|
|
|
168
285
|
nuxt.options.runtimeConfig.public.users = {
|
|
169
286
|
profilePath: settings.profilePath,
|
|
170
287
|
mcp: settings.mcp === true,
|
|
171
|
-
pages: { admin: adminPagePath }
|
|
288
|
+
pages: { admin: adminPagePath },
|
|
289
|
+
...terms ? { terms: { version: terms.version, url: terms.url, ...terms.privacyUrl ? { privacyUrl: terms.privacyUrl } : {} } } : {},
|
|
290
|
+
avatarUpload,
|
|
291
|
+
maxAvatarBytes: options.maxAvatarBytes ?? USERS_MAX_AVATAR_BYTES
|
|
172
292
|
};
|
|
173
293
|
}
|
|
174
294
|
});
|
package/dist/runtime/access.js
CHANGED
|
@@ -16,12 +16,12 @@ 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 and
|
|
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
|
|
23
|
-
// under their own `:pii` permission (`crew:pii`, `shifts:pii`).
|
|
24
|
-
"pii": { label: "See users' phone
|
|
23
|
+
// under their own `:pii` permission (`crew:pii`, `shifts:pii`).
|
|
24
|
+
"pii": { label: "See users' phone numbers", description: "See and change the phone number of other users.", grantTo: ["admin"] }
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
export const USERS_SELF_SERVICE = ["profile:read", "profile:write"];
|
|
@@ -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;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { usersApi } from "../../utils/api";
|
|
3
|
+
import UsersTermsText from "./UsersTermsText.vue";
|
|
4
|
+
import { $fetch, reloadNuxtApp, useAction, useAuth, useFormat, useLocaleLink, useModuleT, useNuxtApp } from "#imports";
|
|
5
|
+
defineOptions({ name: "UsersTermsGate" });
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
status: { type: Object, required: true }
|
|
8
|
+
});
|
|
9
|
+
const emit = defineEmits(["close"]);
|
|
10
|
+
const t = useModuleT("users");
|
|
11
|
+
const format = useFormat();
|
|
12
|
+
const { localize } = useLocaleLink();
|
|
13
|
+
const { busy, run } = useAction();
|
|
14
|
+
const signingOut = useAction();
|
|
15
|
+
const i18n = useNuxtApp().$i18n;
|
|
16
|
+
async function accept() {
|
|
17
|
+
const status = await run(async () => {
|
|
18
|
+
try {
|
|
19
|
+
return await $fetch(usersApi.me.terms, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
body: { version: props.status.current.version, ...i18n?.locale?.value ? { locale: i18n.locale.value } : {} }
|
|
22
|
+
});
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error.data?.data?.code === "outdated_version") reloadNuxtApp();
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}, { success: t("terms.gate.accepted", "Terms accepted"), error: t("terms.gate.acceptFailed", "The terms could not be accepted.") });
|
|
28
|
+
if (status) emit("close", status);
|
|
29
|
+
}
|
|
30
|
+
function signOut() {
|
|
31
|
+
return signingOut.run(() => useAuth().logout(), { error: t("terms.gate.signOutFailed", "You could not be signed out.") });
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<UModal
|
|
37
|
+
:title="status.accepted ? t('terms.gate.changedTitle', 'Our terms have changed') : t('terms.gate.title', 'Accept our terms')"
|
|
38
|
+
:description="status.accepted ? t('terms.gate.changedDescription', 'You accepted version {version} on {date}. Read and accept the new terms to go on.', { version: status.accepted.version, date: format.date(status.accepted.acceptedAt) }) : t('terms.gate.description', 'Read and accept the terms to go on using your account.')"
|
|
39
|
+
:dismissible="false"
|
|
40
|
+
:close="false"
|
|
41
|
+
>
|
|
42
|
+
<template #body>
|
|
43
|
+
<div
|
|
44
|
+
class="flex flex-col gap-3 text-sm"
|
|
45
|
+
data-users-terms-gate
|
|
46
|
+
>
|
|
47
|
+
<p class="text-highlighted">
|
|
48
|
+
<UsersTermsText :terms="status.current" />
|
|
49
|
+
</p>
|
|
50
|
+
<p class="text-muted">
|
|
51
|
+
{{ t("terms.gate.version", "Version {version}", { version: status.current.version }) }}
|
|
52
|
+
</p>
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
55
|
+
<template #footer>
|
|
56
|
+
<div class="flex w-full flex-wrap justify-end gap-2">
|
|
57
|
+
<UButton
|
|
58
|
+
color="neutral"
|
|
59
|
+
variant="outline"
|
|
60
|
+
icon="i-lucide-scroll-text"
|
|
61
|
+
:to="localize(status.current.url)"
|
|
62
|
+
target="_blank"
|
|
63
|
+
:label="t('terms.gate.read', 'Read the terms')"
|
|
64
|
+
/>
|
|
65
|
+
<UButton
|
|
66
|
+
color="neutral"
|
|
67
|
+
variant="ghost"
|
|
68
|
+
icon="i-lucide-log-out"
|
|
69
|
+
:loading="signingOut.busy.value"
|
|
70
|
+
:label="t('terms.gate.signOut', 'Sign out')"
|
|
71
|
+
@click="signOut"
|
|
72
|
+
/>
|
|
73
|
+
<UButton
|
|
74
|
+
icon="i-lucide-check"
|
|
75
|
+
:loading="busy"
|
|
76
|
+
:label="t('terms.gate.accept', 'Accept terms')"
|
|
77
|
+
@click="accept"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
</UModal>
|
|
82
|
+
</template>
|
|
@@ -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;
|