@frigear-nu/users 1.1.3 → 1.1.4
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 +21 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +25 -30
- package/dist/runtime/app/components/UserCreateSlideover.vue +2 -1
- package/dist/runtime/app/composables/useUserActions.d.ts +1 -1
- package/dist/runtime/app/composables/useUserActions.js +6 -3
- package/dist/runtime/app/pages/admin-user.vue +14 -5
- package/dist/runtime/app/pages/admin.vue +85 -75
- package/dist/runtime/app/pages/revert-email-change.vue +3 -2
- package/dist/runtime/app/pages/verify-email-change.vue +3 -2
- package/dist/runtime/app/tabs/Overview.vue +51 -53
- package/dist/runtime/app/utils/admin-user.d.ts +4 -17
- package/dist/runtime/app/widgets/NewUsers.vue +2 -1
- package/dist/runtime/app/widgets/NewUsersStat.vue +2 -1
- package/dist/runtime/i18n/lang/da.json +5 -3
- package/dist/runtime/i18n/lang/en.json +5 -3
- package/dist/runtime/server/routes/admin/new.get.js +2 -8
- package/dist/runtime/server/routes/admin/user-resend.post.js +3 -13
- package/dist/runtime/server/routes/admin/user.delete.js +6 -15
- package/dist/runtime/server/routes/admin/user.get.js +6 -16
- package/dist/runtime/server/routes/admin/user.patch.js +13 -23
- package/dist/runtime/server/routes/admin/users.get.js +24 -28
- package/dist/runtime/server/routes/admin/users.post.js +12 -13
- package/dist/runtime/server/routes/me/email-change-confirm.post.js +7 -11
- package/dist/runtime/server/routes/me/email-change-revert.get.js +2 -1
- package/dist/runtime/server/routes/me/email-change-revert.post.js +5 -7
- package/dist/runtime/server/routes/me/email-change.get.js +2 -1
- package/dist/runtime/server/routes/me/{change-email.post.js → email.put.js} +9 -10
- package/dist/runtime/server/routes/me/{change-password.post.js → password.put.js} +4 -5
- package/dist/runtime/server/routes/me/profile.patch.js +22 -0
- package/dist/runtime/server/schemas.d.ts +7 -0
- package/dist/runtime/server/schemas.js +4 -0
- package/dist/runtime/server/user-store.js +5 -3
- package/dist/runtime/server/utils/admin.d.ts +15 -3
- package/dist/runtime/server/utils/admin.js +16 -15
- package/dist/runtime/server/utils/dto.d.ts +19 -0
- package/dist/runtime/server/utils/dto.js +22 -0
- package/dist/runtime/server/utils/email.d.ts +18 -0
- package/dist/runtime/server/utils/email.js +18 -0
- package/dist/runtime/utils/api.d.ts +33 -0
- package/dist/runtime/utils/api.js +32 -0
- package/dist/runtime/utils/index.d.ts +3 -1
- package/dist/runtime/utils/index.js +1 -0
- package/dist/types.d.mts +1 -1
- package/package.json +16 -11
- package/dist/runtime/server/routes/me/profile.post.js +0 -17
- /package/dist/runtime/server/routes/me/{change-email.post.d.ts → email.put.d.ts} +0 -0
- /package/dist/runtime/server/routes/me/{change-password.post.d.ts → password.put.d.ts} +0 -0
- /package/dist/runtime/server/routes/me/{profile.post.d.ts → profile.patch.d.ts} +0 -0
package/dist/module.d.mts
CHANGED
|
@@ -33,6 +33,26 @@ type ModuleOptions = {
|
|
|
33
33
|
mcp?: boolean;
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
+
/** A user as the users admin API returns it (`GET /api/admin/users/:id`, create and edit): an allowlist, never the row. */
|
|
37
|
+
type AdminUserDto = {
|
|
38
|
+
id: number;
|
|
39
|
+
name: string;
|
|
40
|
+
email: string;
|
|
41
|
+
/** Only when an authorization module added the `role` column. */
|
|
42
|
+
role?: string;
|
|
43
|
+
avatar: string | null;
|
|
44
|
+
emailVerifiedAt: string | null;
|
|
45
|
+
lastLoginAt: string | null;
|
|
46
|
+
createdAt: string;
|
|
47
|
+
};
|
|
48
|
+
/** The signed-in user's own profile, as the self-service routes return it. */
|
|
49
|
+
type ProfileDto = {
|
|
50
|
+
id: number;
|
|
51
|
+
name: string;
|
|
52
|
+
email: string;
|
|
53
|
+
avatar: string | null;
|
|
54
|
+
emailVerifiedAt: string | null;
|
|
55
|
+
};
|
|
36
56
|
|
|
37
57
|
declare module 'nitropack' {
|
|
38
58
|
interface NitroRuntimeHooks {
|
|
@@ -58,4 +78,4 @@ declare module 'nuxt/schema' {
|
|
|
58
78
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
59
79
|
|
|
60
80
|
export { _default as default };
|
|
61
|
-
export type { ModuleOptions, PublicModuleOptions };
|
|
81
|
+
export type { AdminUserDto, ModuleOptions, ProfileDto, PublicModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addServerImportsDir,
|
|
2
|
-
import { registerTailwindSource, registerLocales, registerDatabaseTable, inlineModuleRuntime,
|
|
1
|
+
import { defineNuxtModule, createResolver, addServerImportsDir, hasNuxtModule } from '@nuxt/kit';
|
|
2
|
+
import { registerTailwindSource, registerLocales, registerDatabaseTable, inlineModuleRuntime, addModulePages, addModuleRoutes, resolvePagePath, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
|
|
3
3
|
import { setAuthUserStore, addAuthScope } from '@frigear-nu/auth/utils';
|
|
4
4
|
|
|
5
5
|
const module$1 = defineNuxtModule({
|
|
@@ -51,22 +51,18 @@ const module$1 = defineNuxtModule({
|
|
|
51
51
|
nuxt.hook("notify:email:templates", (sources) => sources.push({ dir: resolver.resolve("./runtime/emails") }));
|
|
52
52
|
addServerImportsDir(resolver.resolve("./runtime/server/utils"));
|
|
53
53
|
inlineModuleRuntime(nuxt, resolver);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
]
|
|
59
|
-
addServerHandler({ route: moduleApiUrl("users", path), method: "post", handler: resolver.resolve(`./runtime/server/routes/me/${file}`) });
|
|
60
|
-
}
|
|
54
|
+
const selfRoutes = [
|
|
55
|
+
{ method: "patch", path: "me", file: "me/profile.patch" },
|
|
56
|
+
{ method: "put", path: "me/email", file: "me/email.put" },
|
|
57
|
+
{ method: "put", path: "me/password", file: "me/password.put" }
|
|
58
|
+
];
|
|
61
59
|
if (settings.verifyEmailChange) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
addServerHandler({ route: moduleApiUrl("users", path), method, handler: resolver.resolve(`./runtime/server/routes/me/${file}`) });
|
|
69
|
-
}
|
|
60
|
+
selfRoutes.push(
|
|
61
|
+
{ method: "get", path: "email-change", file: "me/email-change.get" },
|
|
62
|
+
{ method: "post", path: "email-change/confirm", file: "me/email-change-confirm.post" },
|
|
63
|
+
{ method: "get", path: "email-change/revert", file: "me/email-change-revert.get" },
|
|
64
|
+
{ method: "post", path: "email-change/revert", file: "me/email-change-revert.post" }
|
|
65
|
+
);
|
|
70
66
|
nuxt.hook("modules:done", () => {
|
|
71
67
|
if (!hasNuxtModule("@nuxt/ui", nuxt)) {
|
|
72
68
|
console.warn("[@frigear-nu/users] `settings.verifyEmailChange` is on, but `@nuxt/ui` is not installed: add your own pages at `/auth/verify-email-change` and `/auth/revert-email-change` (see the users module docs).");
|
|
@@ -82,6 +78,7 @@ const module$1 = defineNuxtModule({
|
|
|
82
78
|
schema: (dialect) => `./runtime/db/email-changes.${dialect}`
|
|
83
79
|
});
|
|
84
80
|
}
|
|
81
|
+
addModuleRoutes(resolver, selfRoutes, { base: "/api/users" });
|
|
85
82
|
if (settings.mcp === true) {
|
|
86
83
|
const { addMcpDefinitions } = await import('@frigear-nu/mcp/utils');
|
|
87
84
|
addAuthScope(nuxt, { name: "profile:read", description: "Read your own name, email and role (MCP)" });
|
|
@@ -96,19 +93,17 @@ const module$1 = defineNuxtModule({
|
|
|
96
93
|
}
|
|
97
94
|
const adminPagePath = withAdmin && withAdminShell ? resolvePagePath(adminOptions.page ?? true, (await import('@frigear-nu/admin/utils')).adminRoute(nuxt, "users")) : void 0;
|
|
98
95
|
if (withAdmin) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
]
|
|
110
|
-
addServerHandler({ route: path, method, handler: resolver.resolve(`./runtime/server/routes/admin/${file}`) });
|
|
111
|
-
}
|
|
96
|
+
addModuleRoutes(resolver, [
|
|
97
|
+
{ method: "get", path: "", file: "admin/users.get" },
|
|
98
|
+
{ method: "post", path: "", file: "admin/users.post" },
|
|
99
|
+
{ method: "get", path: "new", file: "admin/new.get" },
|
|
100
|
+
{ method: "get", path: "stats", file: "admin/stats.get" },
|
|
101
|
+
{ method: "get", path: "roles", file: "admin/roles.get" },
|
|
102
|
+
{ method: "get", path: ":id", file: "admin/user.get" },
|
|
103
|
+
{ method: "patch", path: ":id", file: "admin/user.patch" },
|
|
104
|
+
{ method: "delete", path: ":id", file: "admin/user.delete" },
|
|
105
|
+
{ method: "post", path: ":id/resend", file: "admin/user-resend.post" }
|
|
106
|
+
], { base: "/api/admin/users" });
|
|
112
107
|
if (adminPagePath) {
|
|
113
108
|
addModulePages("@frigear-nu/users", resolver, [
|
|
114
109
|
{ name: "users-admin", path: adminPagePath, file: "./runtime/app/pages/admin.vue" },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { usersApi } from "../../utils/api";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
defineOptions({ name: "UsersUserCreateSlideover" });
|
|
4
5
|
const props = defineProps({
|
|
@@ -19,7 +20,7 @@ const roleLabel = (value) => t(`admin.roleNames.${value}`, value.charAt(0).toUpp
|
|
|
19
20
|
const roleItems = computed(() => (props.roles ?? []).map((value) => ({ label: roleLabel(value), value })));
|
|
20
21
|
async function save(event) {
|
|
21
22
|
const created = await run(
|
|
22
|
-
() => $fetch(
|
|
23
|
+
() => $fetch(usersApi.admin.users, {
|
|
23
24
|
method: "POST",
|
|
24
25
|
body: { ...event.data, role: roleItems.value.length && event.data.role ? event.data.role : void 0 }
|
|
25
26
|
}),
|
|
@@ -14,7 +14,7 @@ export interface UserMenuOptions {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Everything staff do to a user: `create` (a slideover), `remove` (confirm, toast, refresh) and `menu(user)` for the
|
|
17
|
+
* Everything staff do to a user: `create` (a slideover, then the new user's page), `remove` (confirm, toast, refresh) and `menu(user)` for the
|
|
18
18
|
* `RowMenu` of the list rows and the detail heading, ordered Open, sign-in link, extras, then Delete in its own group.
|
|
19
19
|
*/
|
|
20
20
|
export declare function useUserActions(): {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import UserCreateSlideover from "../components/UserCreateSlideover.vue";
|
|
2
2
|
import { ADMIN_USERS_KEY } from "../utils/admin-user.js";
|
|
3
|
+
import { usersApi } from "../../utils/api.js";
|
|
3
4
|
export function useUserActions() {
|
|
4
5
|
const t = useModuleT("users");
|
|
5
6
|
const overlay = useOverlay();
|
|
@@ -10,7 +11,9 @@ export function useUserActions() {
|
|
|
10
11
|
const listPath = computed(() => localize(adminPage.replace(/\/+$/, "")));
|
|
11
12
|
const userPath = (id) => `${listPath.value}/${id}`;
|
|
12
13
|
async function create(options = {}) {
|
|
13
|
-
|
|
14
|
+
const created = await overlay.create(UserCreateSlideover).open({ roles: options.roles ?? [] });
|
|
15
|
+
if (created) await navigateTo(userPath(created.id));
|
|
16
|
+
return created;
|
|
14
17
|
}
|
|
15
18
|
async function remove(user, options = {}) {
|
|
16
19
|
const confirmed = await confirm({
|
|
@@ -21,7 +24,7 @@ export function useUserActions() {
|
|
|
21
24
|
});
|
|
22
25
|
if (!confirmed) return false;
|
|
23
26
|
const done = await run(
|
|
24
|
-
() => $fetch(
|
|
27
|
+
() => $fetch(usersApi.admin.user(user.id), { method: "DELETE" }).then(() => true),
|
|
25
28
|
{ success: t("admin.deleted", "User deleted.") }
|
|
26
29
|
);
|
|
27
30
|
if (!done) return false;
|
|
@@ -31,7 +34,7 @@ export function useUserActions() {
|
|
|
31
34
|
}
|
|
32
35
|
async function resend(user) {
|
|
33
36
|
const sent = await run(
|
|
34
|
-
() => $fetch(
|
|
37
|
+
() => $fetch(usersApi.admin.resend(user.id), { method: "POST" }).then(() => true),
|
|
35
38
|
{ success: t("admin.resent", "Sign-in link sent.") }
|
|
36
39
|
);
|
|
37
40
|
return !!sent;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { usersApi } from "../../utils/api";
|
|
2
3
|
import OverviewTab from "../tabs/Overview.vue";
|
|
3
4
|
import { useUserActions } from "../composables/useUserActions";
|
|
4
5
|
defineOptions({ name: "UsersAdminUserPage" });
|
|
@@ -6,7 +7,8 @@ const t = useModuleT("users");
|
|
|
6
7
|
const route = useRoute();
|
|
7
8
|
const actions = useUserActions();
|
|
8
9
|
const id = computed(() => route.params.id);
|
|
9
|
-
const { data: user, refresh, error } = await useFetch(() =>
|
|
10
|
+
const { data: user, refresh, error } = await useFetch(() => usersApi.admin.user(id.value));
|
|
11
|
+
const forbidden = computed(() => [401, 403].includes(error.value?.statusCode ?? 0));
|
|
10
12
|
const Tabs = resolveComponent("WidgetTabs");
|
|
11
13
|
const tabs = typeof Tabs === "string" ? void 0 : Tabs;
|
|
12
14
|
const menu = computed(() => user.value ? actions.menu(user.value, {
|
|
@@ -21,7 +23,14 @@ const menu = computed(() => user.value ? actions.menu(user.value, {
|
|
|
21
23
|
<template>
|
|
22
24
|
<div class="flex flex-col gap-4">
|
|
23
25
|
<UEmpty
|
|
24
|
-
v-if="error
|
|
26
|
+
v-if="error && error.statusCode !== 404"
|
|
27
|
+
:icon="forbidden ? 'i-lucide-lock' : 'i-lucide-circle-alert'"
|
|
28
|
+
:title="forbidden ? t('admin.forbidden', 'You do not have access to users') : t('admin.detail.loadFailed', 'The user could not be loaded')"
|
|
29
|
+
:description="errorMessage(error, '')"
|
|
30
|
+
:actions="forbidden ? [] : [{ label: t('admin.tryAgain', 'Try again'), icon: 'i-lucide-rotate-ccw', color: 'neutral', variant: 'outline', onClick: () => refresh() }]"
|
|
31
|
+
/>
|
|
32
|
+
<UEmpty
|
|
33
|
+
v-else-if="error || !user"
|
|
25
34
|
icon="i-lucide-user-x"
|
|
26
35
|
:title="t('admin.detail.notFound', 'User not found')"
|
|
27
36
|
:description="t('admin.detail.notFoundHint', 'It may have been deleted.')"
|
|
@@ -34,9 +43,9 @@ const menu = computed(() => user.value ? actions.menu(user.value, {
|
|
|
34
43
|
:breadcrumb="[{ label: t('admin.title', 'Users'), to: actions.listPath.value }, { label: user.name }]"
|
|
35
44
|
>
|
|
36
45
|
<template #badge>
|
|
37
|
-
<
|
|
38
|
-
:
|
|
39
|
-
|
|
46
|
+
<StatusBadge
|
|
47
|
+
:status="user.emailVerifiedAt ? 'verified' : 'unverified'"
|
|
48
|
+
:colors="{ verified: 'success', unverified: 'warning' }"
|
|
40
49
|
:label="user.emailVerifiedAt ? t('admin.filters.verified', 'Verified') : t('admin.filters.unverified', 'Unverified')"
|
|
41
50
|
/>
|
|
42
51
|
</template>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { usersApi } from "../../utils/api";
|
|
2
3
|
import { ADMIN_USERS_KEY } from "../utils/admin-user";
|
|
3
4
|
import { useUserActions } from "../composables/useUserActions";
|
|
4
5
|
defineOptions({ name: "UsersAdminPage" });
|
|
@@ -11,20 +12,22 @@ const { page, pageSize, search, sort: sortState, filters, query, filtered, reset
|
|
|
11
12
|
});
|
|
12
13
|
const sort = useTableSort(null, sortState);
|
|
13
14
|
const { sorting } = sort;
|
|
14
|
-
const { data, status } = await useFetch(
|
|
15
|
+
const { data, status, error, refresh } = await useFetch(usersApi.admin.users, {
|
|
15
16
|
key: ADMIN_USERS_KEY,
|
|
16
|
-
query
|
|
17
|
-
default: () => ({ items: [], total: 0, page: 1, pageSize: 20, hasRoles: false, hasSubscriptions: false, roles: [] })
|
|
17
|
+
query
|
|
18
18
|
});
|
|
19
|
-
const
|
|
20
|
-
const
|
|
19
|
+
const rows = computed(() => data.value?.items ?? []);
|
|
20
|
+
const hasRoles = computed(() => data.value?.hasRoles ?? false);
|
|
21
|
+
const hasSubscriptions = computed(() => data.value?.hasSubscriptions ?? false);
|
|
22
|
+
const roles = computed(() => data.value?.roles ?? []);
|
|
23
|
+
const forbidden = computed(() => [401, 403].includes(error.value?.statusCode ?? 0));
|
|
21
24
|
const roleLabel = (value) => t(`admin.roleNames.${value}`, value.charAt(0).toUpperCase() + value.slice(1));
|
|
22
|
-
const roleItems = computed(() =>
|
|
25
|
+
const roleItems = computed(() => roles.value.map((value) => ({ label: roleLabel(value), value })));
|
|
23
26
|
const roleFilterItems = computed(() => [{ label: t("admin.filters.allRoles", "All roles"), value: "all" }, ...roleItems.value]);
|
|
24
27
|
const pending = computed(() => status.value === "pending");
|
|
25
|
-
const loading = computed(() => pending.value && !data.value
|
|
26
|
-
const refreshing = computed(() => pending.value && !!data.value
|
|
27
|
-
const
|
|
28
|
+
const loading = computed(() => pending.value && !data.value);
|
|
29
|
+
const refreshing = computed(() => pending.value && !!data.value);
|
|
30
|
+
const StatusBadge = resolveComponent("StatusBadge");
|
|
28
31
|
const TableIdentity = resolveComponent("TableIdentity");
|
|
29
32
|
const RowMenu = resolveComponent("RowMenu");
|
|
30
33
|
const dateCell = (value) => value ? h("time", { datetime: value, title: format.dateTime(value), class: "tabular-nums" }, format.date(value)) : emptyCell();
|
|
@@ -45,18 +48,18 @@ const columns = computed(() => [
|
|
|
45
48
|
}] : [],
|
|
46
49
|
...hasSubscriptions.value ? [{
|
|
47
50
|
id: "subscription",
|
|
48
|
-
header: t("admin.subscription", "
|
|
51
|
+
header: t("admin.subscription", "Membership"),
|
|
49
52
|
cell: ({ row }) => {
|
|
50
53
|
const subscription = row.original.subscription;
|
|
51
|
-
return subscription ? h(
|
|
54
|
+
return subscription ? h(StatusBadge, { status: subscription.status, label: subscription.planKey ?? subscription.status }) : emptyCell();
|
|
52
55
|
}
|
|
53
56
|
}] : [],
|
|
54
57
|
{
|
|
55
58
|
id: "verified",
|
|
56
59
|
header: t("admin.verified", "Verified"),
|
|
57
|
-
cell: ({ row }) => h(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
cell: ({ row }) => h(StatusBadge, {
|
|
61
|
+
status: row.original.emailVerifiedAt ? "verified" : "unverified",
|
|
62
|
+
colors: { verified: "success" },
|
|
60
63
|
label: row.original.emailVerifiedAt ? t("admin.filters.verified", "Verified") : t("admin.filters.unverified", "Unverified")
|
|
61
64
|
})
|
|
62
65
|
},
|
|
@@ -81,10 +84,7 @@ const verifiedOptions = computed(() => [
|
|
|
81
84
|
function openUser(_event, row) {
|
|
82
85
|
return navigateTo(actions.userPath(row.original.id));
|
|
83
86
|
}
|
|
84
|
-
|
|
85
|
-
const created = await actions.create({ roles: hasRoles.value ? data.value.roles : [] });
|
|
86
|
-
if (created) await navigateTo(actions.userPath(created.id));
|
|
87
|
-
}
|
|
87
|
+
const addUser = () => actions.create({ roles: hasRoles.value ? roles.value : [] });
|
|
88
88
|
</script>
|
|
89
89
|
|
|
90
90
|
<template>
|
|
@@ -92,72 +92,82 @@ async function addUser() {
|
|
|
92
92
|
<PageHeading :title="t('admin.title', 'Users')">
|
|
93
93
|
<template #actions>
|
|
94
94
|
<UButton
|
|
95
|
-
icon="i-lucide-
|
|
95
|
+
icon="i-lucide-plus"
|
|
96
96
|
:label="t('admin.create', 'Add user')"
|
|
97
97
|
@click="addUser"
|
|
98
98
|
/>
|
|
99
99
|
</template>
|
|
100
100
|
</PageHeading>
|
|
101
101
|
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
/>
|
|
110
|
-
<USelect
|
|
111
|
-
v-model="filters.verified"
|
|
112
|
-
:items="verifiedOptions"
|
|
113
|
-
class="w-40"
|
|
114
|
-
/>
|
|
115
|
-
<USelect
|
|
116
|
-
v-if="hasRoles"
|
|
117
|
-
v-model="filters.role"
|
|
118
|
-
:items="roleFilterItems"
|
|
119
|
-
class="w-48"
|
|
120
|
-
icon="i-lucide-shield"
|
|
121
|
-
/>
|
|
122
|
-
<UButton
|
|
123
|
-
v-if="filtered"
|
|
124
|
-
variant="ghost"
|
|
125
|
-
color="neutral"
|
|
126
|
-
icon="i-lucide-x"
|
|
127
|
-
:label="t('admin.filters.clear', 'Clear filters')"
|
|
128
|
-
@click="reset"
|
|
129
|
-
/>
|
|
130
|
-
</PageToolbar>
|
|
102
|
+
<UEmpty
|
|
103
|
+
v-if="error && !data"
|
|
104
|
+
:icon="forbidden ? 'i-lucide-lock' : 'i-lucide-circle-alert'"
|
|
105
|
+
:title="forbidden ? t('admin.forbidden', 'You do not have access to users') : t('admin.loadFailed', 'Users could not be loaded')"
|
|
106
|
+
:description="errorMessage(error, '')"
|
|
107
|
+
:actions="forbidden ? [] : [{ label: t('admin.tryAgain', 'Try again'), icon: 'i-lucide-rotate-ccw', color: 'neutral', variant: 'outline', onClick: () => refresh() }]"
|
|
108
|
+
/>
|
|
131
109
|
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
110
|
+
<template v-else>
|
|
111
|
+
<PageToolbar>
|
|
112
|
+
<UInput
|
|
113
|
+
v-model="search"
|
|
114
|
+
class="w-full max-w-sm"
|
|
115
|
+
icon="i-lucide-search"
|
|
116
|
+
:loading="pending"
|
|
117
|
+
:placeholder="t('admin.search', 'Search name, email or role...')"
|
|
118
|
+
/>
|
|
119
|
+
<USelect
|
|
120
|
+
v-model="filters.verified"
|
|
121
|
+
:items="verifiedOptions"
|
|
122
|
+
class="w-40"
|
|
123
|
+
/>
|
|
124
|
+
<USelect
|
|
125
|
+
v-if="hasRoles"
|
|
126
|
+
v-model="filters.role"
|
|
127
|
+
:items="roleFilterItems"
|
|
128
|
+
class="w-48"
|
|
129
|
+
icon="i-lucide-shield"
|
|
130
|
+
/>
|
|
131
|
+
<UButton
|
|
132
|
+
v-if="filtered"
|
|
133
|
+
variant="ghost"
|
|
134
|
+
color="neutral"
|
|
135
|
+
icon="i-lucide-x"
|
|
136
|
+
:label="t('admin.filters.clear', 'Clear filters')"
|
|
137
|
+
@click="reset"
|
|
138
|
+
/>
|
|
139
|
+
</PageToolbar>
|
|
140
|
+
|
|
141
|
+
<TableCard
|
|
142
|
+
:loading="loading"
|
|
143
|
+
:refreshing="refreshing"
|
|
144
144
|
>
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
145
|
+
<UTable
|
|
146
|
+
v-model:sorting="sorting"
|
|
147
|
+
:data="rows"
|
|
148
|
+
:columns="columns"
|
|
149
|
+
:sorting-options="{ manualSorting: true }"
|
|
150
|
+
:ui="tableUi({}, { sticky: true })"
|
|
151
|
+
sticky
|
|
152
|
+
@select="openUser"
|
|
153
|
+
>
|
|
154
|
+
<template #empty>
|
|
155
|
+
<UEmpty
|
|
156
|
+
icon="i-lucide-users"
|
|
157
|
+
variant="naked"
|
|
158
|
+
:title="t('admin.empty', 'No users match')"
|
|
159
|
+
:actions="[filtered ? { label: t('admin.filters.clear', 'Clear filters'), color: 'neutral', variant: 'outline', onClick: reset } : { label: t('admin.create', 'Add user'), icon: 'i-lucide-plus', onClick: addUser }]"
|
|
160
|
+
/>
|
|
161
|
+
</template>
|
|
162
|
+
</UTable>
|
|
163
|
+
<template #footer>
|
|
164
|
+
<TablePagination
|
|
165
|
+
v-model:page="page"
|
|
166
|
+
v-model:page-size="pageSize"
|
|
167
|
+
:total="data?.total ?? 0"
|
|
151
168
|
/>
|
|
152
169
|
</template>
|
|
153
|
-
</
|
|
154
|
-
|
|
155
|
-
<TablePagination
|
|
156
|
-
v-model:page="page"
|
|
157
|
-
v-model:page-size="pageSize"
|
|
158
|
-
:total="data.total"
|
|
159
|
-
/>
|
|
160
|
-
</template>
|
|
161
|
-
</TableCard>
|
|
170
|
+
</TableCard>
|
|
171
|
+
</template>
|
|
162
172
|
</div>
|
|
163
173
|
</template>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { usersApi } from "../../utils/api";
|
|
2
3
|
defineOptions({ name: "UsersRevertEmailChangePage" });
|
|
3
4
|
const t = useModuleT("users.emailChange");
|
|
4
5
|
const route = useRoute();
|
|
@@ -6,7 +7,7 @@ const { fetch: refreshSession } = useUserSession();
|
|
|
6
7
|
const loginPath = useAuthPages().login;
|
|
7
8
|
const passwordReset = useRuntimeConfig().public.authentication?.passwordReset === true;
|
|
8
9
|
const code = computed(() => typeof route.query.code === "string" ? route.query.code : "");
|
|
9
|
-
const { data: preview, error: previewError } = await useFetch(
|
|
10
|
+
const { data: preview, error: previewError } = await useFetch(usersApi.emailChangeRevert, {
|
|
10
11
|
query: { code },
|
|
11
12
|
immediate: !!code.value
|
|
12
13
|
});
|
|
@@ -22,7 +23,7 @@ async function onRevert() {
|
|
|
22
23
|
reverting.value = true;
|
|
23
24
|
error.value = null;
|
|
24
25
|
try {
|
|
25
|
-
const result = await $fetch(
|
|
26
|
+
const result = await $fetch(usersApi.emailChangeRevert, {
|
|
26
27
|
method: "POST",
|
|
27
28
|
body: { code: code.value }
|
|
28
29
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { usersApi } from "../../utils/api";
|
|
2
3
|
defineOptions({ name: "UsersVerifyEmailChangePage" });
|
|
3
4
|
const t = useModuleT("users.emailChange");
|
|
4
5
|
const route = useRoute();
|
|
@@ -6,7 +7,7 @@ const { loggedIn, user, clear, fetch: refreshSession } = useUserSession();
|
|
|
6
7
|
const loginPath = useAuthPages().login;
|
|
7
8
|
const profilePath = useRuntimeConfig().public.users?.profilePath;
|
|
8
9
|
const code = computed(() => typeof route.query.code === "string" ? route.query.code : "");
|
|
9
|
-
const { data: preview, error: previewError } = await useFetch(
|
|
10
|
+
const { data: preview, error: previewError } = await useFetch(usersApi.emailChange, {
|
|
10
11
|
query: { code },
|
|
11
12
|
immediate: !!code.value,
|
|
12
13
|
// Signing out (wrong account) changes who may confirm.
|
|
@@ -33,7 +34,7 @@ async function onConfirm() {
|
|
|
33
34
|
confirming.value = true;
|
|
34
35
|
error.value = null;
|
|
35
36
|
try {
|
|
36
|
-
const result = await $fetch(
|
|
37
|
+
const result = await $fetch(usersApi.emailChangeConfirm, {
|
|
37
38
|
method: "POST",
|
|
38
39
|
body: { code: code.value }
|
|
39
40
|
});
|