@tiny-server/identity 0.0.0-pre202605241751
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/AccountForm-B2UrGPa4.js +165 -0
- package/dist/AccountHeader-B4SMzQeC.js +31 -0
- package/dist/AccountSettingsMenuItem-BKBN0OZp.js +29 -0
- package/dist/CreatedUpdatedBadges-C4dgPWIl.js +42 -0
- package/dist/DeleteAccountForm-yrL29VdV.js +200 -0
- package/dist/IdentityErrorDetails-CJDjlYx0.js +142 -0
- package/dist/ManageAccountsMenuItem-BgTTH5S8.js +29 -0
- package/dist/ManageRolesMenuItem-DxMd-3i9.js +29 -0
- package/dist/RoleForm-DYxKoGmW.js +202 -0
- package/dist/RoleHeader-CoZg-xCl.js +67 -0
- package/dist/api/accounts.d.ts +112 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/login.d.ts +26 -0
- package/dist/api/permissions.d.ts +13 -0
- package/dist/api/roles.d.ts +100 -0
- package/dist/api/status.d.ts +6 -0
- package/dist/components/CreatedUpdatedBadges.d.ts +10 -0
- package/dist/components/IdentityErrorDetails.d.ts +5 -0
- package/dist/components/account/AccountHeader.d.ts +5 -0
- package/dist/components/account/AccountOverviewCard.d.ts +8 -0
- package/dist/components/account/ChangePasswordCard.d.ts +4 -0
- package/dist/components/account/CreateAccountCard.d.ts +1 -0
- package/dist/components/account/DeleteAccountCard.d.ts +6 -0
- package/dist/components/account/ManageAccountCard.d.ts +15 -0
- package/dist/components/account/ManageAccountRolesCard.d.ts +5 -0
- package/dist/components/account/index.d.ts +7 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/role/CreateRoleCard.d.ts +1 -0
- package/dist/components/role/DeleteRoleCard.d.ts +6 -0
- package/dist/components/role/ManageRoleCard.d.ts +6 -0
- package/dist/components/role/PermissionInput.d.ts +17 -0
- package/dist/components/role/RoleHeader.d.ts +5 -0
- package/dist/components/role/RoleOverviewCard.d.ts +5 -0
- package/dist/components/role/index.d.ts +5 -0
- package/dist/constants.d.ts +9 -0
- package/dist/createLucideIcon-DJ4QdTU4.js +74 -0
- package/dist/declarations.d.ts +10 -0
- package/dist/forms/AccountForm.d.ts +22 -0
- package/dist/forms/AccountRolesForm.d.ts +11 -0
- package/dist/forms/ChangePasswordForm.d.ts +15 -0
- package/dist/forms/DeleteAccountForm.d.ts +6 -0
- package/dist/forms/DeleteRoleForm.d.ts +6 -0
- package/dist/forms/LoginForm.d.ts +1 -0
- package/dist/forms/RegisterForm.d.ts +1 -0
- package/dist/forms/RoleForm.d.ts +13 -0
- package/dist/forms/index.d.ts +8 -0
- package/dist/i18n-ZQHvKu9t.js +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +267 -0
- package/dist/key-CmPc9vYA.js +9 -0
- package/dist/login-DP7FSO-S.js +108 -0
- package/dist/manage.accounts-D8nzi0BV.js +60 -0
- package/dist/manage.accounts._id-CTAIEe0D.js +131 -0
- package/dist/manage.accounts.create-CJHdTi4B.js +29 -0
- package/dist/manage.roles-B_WYX8EH.js +68 -0
- package/dist/manage.roles._id-CRO5xYLO.js +108 -0
- package/dist/manage.roles.create-DDNPLNCK.js +29 -0
- package/dist/menu/AccountSettingsMenuItem.d.ts +3 -0
- package/dist/menu/ManageAccountsMenuItem.d.ts +3 -0
- package/dist/menu/ManageRolesMenuItem.d.ts +3 -0
- package/dist/module.d.ts +6 -0
- package/dist/plus-Bhxt0T43.js +8 -0
- package/dist/register-C4hB44_D.js +155 -0
- package/dist/routes/login.d.ts +1 -0
- package/dist/routes/manage.accounts.$id.d.ts +1 -0
- package/dist/routes/manage.accounts.create.d.ts +1 -0
- package/dist/routes/manage.accounts.d.ts +1 -0
- package/dist/routes/manage.roles.$id.d.ts +1 -0
- package/dist/routes/manage.roles.create.d.ts +1 -0
- package/dist/routes/manage.roles.d.ts +1 -0
- package/dist/routes/register.d.ts +1 -0
- package/dist/routes/settings.account.d.ts +1 -0
- package/dist/settings.account-DITieOTt.js +25 -0
- package/dist/triangle-alert-TOt7wYJV.js +21 -0
- package/dist/useCreateUpdateForm-DnWbYIo0.js +18 -0
- package/dist/user-BmPfMiSO.js +8 -0
- package/dist/utils/i18n.d.ts +2 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/useCreateUpdateForm.d.ts +15 -0
- package/dist/utils/useValidators.d.ts +7 -0
- package/package.json +54 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { jsxs as u, jsx as a, Fragment as x } from "react/jsx-runtime";
|
|
2
|
+
import { usePermissions as A, useSession as U } from "@tiny-server/core";
|
|
3
|
+
import { TextInput as d, PasswordInput as b, Button as k } from "@mantine/core";
|
|
4
|
+
import { Form as n } from "@tiny-server/design";
|
|
5
|
+
import { useMutation as h } from "@tanstack/react-query";
|
|
6
|
+
import { i as S, u as F, e as M, d as T, I as D, c as E, m as L } from "./IdentityErrorDetails-CJDjlYx0.js";
|
|
7
|
+
import { createAccountMutation as q, updateAccountMutation as O } from "./index.js";
|
|
8
|
+
import { u as j } from "./useCreateUpdateForm-DnWbYIo0.js";
|
|
9
|
+
import { d as R } from "./i18n-ZQHvKu9t.js";
|
|
10
|
+
const B = R("AccountForm", {
|
|
11
|
+
en: {
|
|
12
|
+
id: {
|
|
13
|
+
label: "Account ID",
|
|
14
|
+
description: "The unique account ID."
|
|
15
|
+
},
|
|
16
|
+
userName: {
|
|
17
|
+
label: "Username",
|
|
18
|
+
placeholder: "Username",
|
|
19
|
+
description: "The user name to be used for logging in."
|
|
20
|
+
},
|
|
21
|
+
email: {
|
|
22
|
+
label: "E-mail address",
|
|
23
|
+
placeholder: "mail@example.com",
|
|
24
|
+
description: "The primary e-mail address."
|
|
25
|
+
},
|
|
26
|
+
password: {
|
|
27
|
+
label: "Password",
|
|
28
|
+
placeholder: "Password",
|
|
29
|
+
description: "The password to be used for logging in."
|
|
30
|
+
},
|
|
31
|
+
passwordConfirmation: {
|
|
32
|
+
label: "Repeat password",
|
|
33
|
+
placeholder: "Password",
|
|
34
|
+
description: "Repeat the password to ensure that it is correct."
|
|
35
|
+
},
|
|
36
|
+
submitCreate: "Create account",
|
|
37
|
+
submitUpdate: "Save changes",
|
|
38
|
+
errorCreate: "Account creation failed.",
|
|
39
|
+
errorUpdate: "Account update failed."
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
function Z({ account: i, hideIdField: f, hideUserNameField: p, onSuccess: g }) {
|
|
43
|
+
const e = B(), c = A(), C = U().userId, N = h(q()), P = h(O(i?.id ?? "")), s = i ? P : N, l = !c.includes("write.account.all") && !(c.includes("write.account.own") && C === i?.id), t = s.isPending, I = S(), w = F(), y = M(), V = T(), r = j(
|
|
44
|
+
i,
|
|
45
|
+
() => ({
|
|
46
|
+
initialValues: {
|
|
47
|
+
userName: "",
|
|
48
|
+
email: "",
|
|
49
|
+
password: "",
|
|
50
|
+
passwordConfirmation: ""
|
|
51
|
+
},
|
|
52
|
+
validate: {
|
|
53
|
+
userName: I,
|
|
54
|
+
email: w,
|
|
55
|
+
password: y,
|
|
56
|
+
passwordConfirmation: (o, { password: m }) => V(o, m)
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
(o) => ({
|
|
60
|
+
initialValues: {
|
|
61
|
+
email: o.email ?? ""
|
|
62
|
+
},
|
|
63
|
+
validate: {
|
|
64
|
+
email: w
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
), v = () => {
|
|
68
|
+
const o = r.kind === "create" ? {
|
|
69
|
+
userName: r.values.userName.trim(),
|
|
70
|
+
email: r.values.email?.trim() || null,
|
|
71
|
+
password: r.values.password
|
|
72
|
+
} : {
|
|
73
|
+
email: r.values.email?.trim() || null
|
|
74
|
+
};
|
|
75
|
+
s.mutate(o, {
|
|
76
|
+
onSuccess(m) {
|
|
77
|
+
r.resetDirty(), g?.(m.data);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
return /* @__PURE__ */ u(n, { onSubmit: r.onSubmit(v), children: [
|
|
82
|
+
/* @__PURE__ */ u(n.Section, { children: [
|
|
83
|
+
s.error && /* @__PURE__ */ a(n.Alert, { kind: "error", title: e(r.kind === "create" ? "errorCreate" : "errorUpdate"), children: /* @__PURE__ */ a(D, { error: s.error }) }),
|
|
84
|
+
!f && r.kind === "update" && /* @__PURE__ */ a(
|
|
85
|
+
d,
|
|
86
|
+
{
|
|
87
|
+
id: "id",
|
|
88
|
+
label: e("id.label"),
|
|
89
|
+
description: e("id.description"),
|
|
90
|
+
value: i?.id ?? "",
|
|
91
|
+
readOnly: !0
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
!p && r.kind === "create" && /* @__PURE__ */ a(
|
|
95
|
+
d,
|
|
96
|
+
{
|
|
97
|
+
id: "userName",
|
|
98
|
+
label: e("userName.label"),
|
|
99
|
+
placeholder: e("userName.placeholder"),
|
|
100
|
+
description: e("userName.description"),
|
|
101
|
+
maxLength: E,
|
|
102
|
+
readOnly: l,
|
|
103
|
+
disabled: t,
|
|
104
|
+
required: !0,
|
|
105
|
+
autoFocus: !0,
|
|
106
|
+
...r.getInputProps("userName")
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
!p && i && r.kind === "update" && /* @__PURE__ */ a(
|
|
110
|
+
d,
|
|
111
|
+
{
|
|
112
|
+
id: "userName",
|
|
113
|
+
label: e("userName.label"),
|
|
114
|
+
description: e("userName.description"),
|
|
115
|
+
value: i.userName,
|
|
116
|
+
readOnly: !0
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ a(
|
|
120
|
+
d,
|
|
121
|
+
{
|
|
122
|
+
id: "email",
|
|
123
|
+
type: "email",
|
|
124
|
+
label: e("email.label"),
|
|
125
|
+
placeholder: e("email.placeholder"),
|
|
126
|
+
description: e("email.description"),
|
|
127
|
+
maxLength: L,
|
|
128
|
+
readOnly: l,
|
|
129
|
+
disabled: t,
|
|
130
|
+
...r.getInputProps("email")
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
r.kind === "create" && /* @__PURE__ */ u(x, { children: [
|
|
134
|
+
/* @__PURE__ */ a(
|
|
135
|
+
b,
|
|
136
|
+
{
|
|
137
|
+
id: "password",
|
|
138
|
+
label: e("password.label"),
|
|
139
|
+
placeholder: e("password.placeholder"),
|
|
140
|
+
description: e("password.description"),
|
|
141
|
+
disabled: t,
|
|
142
|
+
required: !0,
|
|
143
|
+
...r.getInputProps("password")
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
/* @__PURE__ */ a(
|
|
147
|
+
b,
|
|
148
|
+
{
|
|
149
|
+
id: "passwordConfirmation",
|
|
150
|
+
label: e("passwordConfirmation.label"),
|
|
151
|
+
placeholder: e("passwordConfirmation.placeholder"),
|
|
152
|
+
description: e("passwordConfirmation.description"),
|
|
153
|
+
disabled: t,
|
|
154
|
+
required: !0,
|
|
155
|
+
...r.getInputProps("passwordConfirmation")
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
] })
|
|
159
|
+
] }),
|
|
160
|
+
!l && /* @__PURE__ */ a(n.Footer, { children: /* @__PURE__ */ a(k, { type: "submit", loading: s.isPending, disabled: s.isPending || !r.isDirty(), children: e(r.kind === "create" ? "submitCreate" : "submitUpdate") }) })
|
|
161
|
+
] });
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
Z as A
|
|
165
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { Group as t, Avatar as i } from "@mantine/core";
|
|
3
|
+
import { SectionCard as o } from "@tiny-server/design";
|
|
4
|
+
import { Extension as s } from "@tiny-server/core";
|
|
5
|
+
import { C as m } from "./CreatedUpdatedBadges-C4dgPWIl.js";
|
|
6
|
+
function u({ account: e }) {
|
|
7
|
+
const a = {
|
|
8
|
+
color: "initials",
|
|
9
|
+
size: "lg",
|
|
10
|
+
name: e.userName
|
|
11
|
+
};
|
|
12
|
+
return /* @__PURE__ */ r(
|
|
13
|
+
o.Header,
|
|
14
|
+
{
|
|
15
|
+
illustration: /* @__PURE__ */ r(
|
|
16
|
+
s,
|
|
17
|
+
{
|
|
18
|
+
name: "avatar",
|
|
19
|
+
params: { userId: e.id, ...a },
|
|
20
|
+
fallback: /* @__PURE__ */ r(i, { ...a })
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
title: e.userName,
|
|
24
|
+
titleProps: { size: "md", fw: "semibold" },
|
|
25
|
+
subTitle: /* @__PURE__ */ r(t, { wrap: "wrap", gap: "xs", children: /* @__PURE__ */ r(m, { entity: e }) })
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
u as A
|
|
31
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { withPermissions as s, useApp as c } from "@tiny-server/core";
|
|
3
|
+
import { U as i } from "./user-BmPfMiSO.js";
|
|
4
|
+
import { d as r } from "./i18n-ZQHvKu9t.js";
|
|
5
|
+
const m = r("AccountSettingsMenuItem", {
|
|
6
|
+
en: {
|
|
7
|
+
label: "Account",
|
|
8
|
+
description: "Manage your account settings."
|
|
9
|
+
}
|
|
10
|
+
}), d = s(
|
|
11
|
+
{ permissions: ["read.account.own"] },
|
|
12
|
+
(o) => {
|
|
13
|
+
const t = m(), { MenuItem: n } = c().components;
|
|
14
|
+
return /* @__PURE__ */ e(
|
|
15
|
+
n,
|
|
16
|
+
{
|
|
17
|
+
label: t("label"),
|
|
18
|
+
description: t("description"),
|
|
19
|
+
to: "/settings/account",
|
|
20
|
+
leftSection: /* @__PURE__ */ e(i, { size: "1em" }),
|
|
21
|
+
...o
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
export {
|
|
27
|
+
d as AccountSettingsMenuItem,
|
|
28
|
+
d as default
|
|
29
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsxs as i, Fragment as c, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip as t, Badge as o } from "@mantine/core";
|
|
3
|
+
import { formatDate as r, formatDateTime as l } from "@tiny-server/core";
|
|
4
|
+
import { c as d } from "./createLucideIcon-DJ4QdTU4.js";
|
|
5
|
+
const n = [
|
|
6
|
+
[
|
|
7
|
+
"path",
|
|
8
|
+
{
|
|
9
|
+
d: "M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",
|
|
10
|
+
key: "o6klzx"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
|
|
14
|
+
[
|
|
15
|
+
"path",
|
|
16
|
+
{
|
|
17
|
+
d: "M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",
|
|
18
|
+
key: "zhnas1"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
], h = d("file-pen", n);
|
|
22
|
+
const p = [
|
|
23
|
+
[
|
|
24
|
+
"path",
|
|
25
|
+
{
|
|
26
|
+
d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
|
|
27
|
+
key: "1oefj6"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
|
|
31
|
+
["path", { d: "M9 15h6", key: "cctwl0" }],
|
|
32
|
+
["path", { d: "M12 18v-6", key: "17g6i2" }]
|
|
33
|
+
], s = d("file-plus", p);
|
|
34
|
+
function z({ entity: a }) {
|
|
35
|
+
return /* @__PURE__ */ i(c, { children: [
|
|
36
|
+
/* @__PURE__ */ e(t, { label: l(a.createdOn), children: /* @__PURE__ */ e(o, { color: "gray", variant: "light", leftSection: /* @__PURE__ */ e(s, { size: "1em" }), children: r(a.createdOn) }) }),
|
|
37
|
+
/* @__PURE__ */ e(t, { label: l(a.updatedOn), children: /* @__PURE__ */ e(o, { color: "gray", variant: "light", leftSection: /* @__PURE__ */ e(h, { size: "1em" }), children: r(a.updatedOn) }) })
|
|
38
|
+
] });
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
z as C
|
|
42
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { withPermissions as S, useSession as y, usePermissions as v } from "@tiny-server/core";
|
|
3
|
+
import { SectionCard as a, Form as i } from "@tiny-server/design";
|
|
4
|
+
import { PasswordInput as A, Button as N, Alert as M, TextInput as V } from "@mantine/core";
|
|
5
|
+
import { useForm as D } from "@mantine/form";
|
|
6
|
+
import { useMutation as C } from "@tanstack/react-query";
|
|
7
|
+
import { updateAccountPasswordMutation as q, deleteAccountMutation as x, logoutMutation as R } from "./index.js";
|
|
8
|
+
import { f as U, e as z, d as E, I as T } from "./IdentityErrorDetails-CJDjlYx0.js";
|
|
9
|
+
import { d as f } from "./i18n-ZQHvKu9t.js";
|
|
10
|
+
import { a as H, T as $ } from "./triangle-alert-TOt7wYJV.js";
|
|
11
|
+
import { A as j } from "./AccountHeader-B4SMzQeC.js";
|
|
12
|
+
import { A as k } from "./AccountForm-B2UrGPa4.js";
|
|
13
|
+
const B = f("ManageAccountPasswordCard", {
|
|
14
|
+
en: {
|
|
15
|
+
title: "Change Password"
|
|
16
|
+
}
|
|
17
|
+
}), ae = S(
|
|
18
|
+
{ operator: "or", permissions: ["write.account.own", "write.account.all"] },
|
|
19
|
+
({ accountId: o }) => {
|
|
20
|
+
const s = B();
|
|
21
|
+
return /* @__PURE__ */ d(a, { children: [
|
|
22
|
+
/* @__PURE__ */ e(a.Header, { title: s("title") }),
|
|
23
|
+
/* @__PURE__ */ e(a.Section, { children: /* @__PURE__ */ e(G, { accountId: o, showCurrentPassword: !1 }) })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
), L = f("DeleteAccountCard", {
|
|
27
|
+
en: {
|
|
28
|
+
title: "Delete Account"
|
|
29
|
+
}
|
|
30
|
+
}), de = S(
|
|
31
|
+
{ operator: "or", permissions: ["write.account.own", "write.account.all"] },
|
|
32
|
+
({ account: o, onSuccess: s }) => {
|
|
33
|
+
const r = L();
|
|
34
|
+
return /* @__PURE__ */ d(a, { children: [
|
|
35
|
+
/* @__PURE__ */ e(a.Header, { title: r("title") }),
|
|
36
|
+
/* @__PURE__ */ e(a.Section, { children: /* @__PURE__ */ e(K, { account: o, onSuccess: s }) })
|
|
37
|
+
] });
|
|
38
|
+
}
|
|
39
|
+
), ce = S(
|
|
40
|
+
{ permissions: ["read.account.all"] },
|
|
41
|
+
({ account: o, hideIdField: s, hideUserNameField: r }) => /* @__PURE__ */ d(a, { children: [
|
|
42
|
+
/* @__PURE__ */ e(j, { account: o }),
|
|
43
|
+
/* @__PURE__ */ e(a.Section, { children: /* @__PURE__ */ e(k, { account: o, hideIdField: s, hideUserNameField: r }) })
|
|
44
|
+
] })
|
|
45
|
+
), Z = f("AccountPasswordForm", {
|
|
46
|
+
en: {
|
|
47
|
+
currentPassword: {
|
|
48
|
+
label: "Current Password",
|
|
49
|
+
placeholder: "Current Password",
|
|
50
|
+
description: "The current password."
|
|
51
|
+
},
|
|
52
|
+
newPassword: {
|
|
53
|
+
label: "New Password",
|
|
54
|
+
placeholder: "New Password",
|
|
55
|
+
description: "The new password to be used for logging in."
|
|
56
|
+
},
|
|
57
|
+
passwordConfirmation: {
|
|
58
|
+
label: "Repeat password",
|
|
59
|
+
placeholder: "Password",
|
|
60
|
+
description: "Repeat the password to ensure that it is correct."
|
|
61
|
+
},
|
|
62
|
+
submit: "Save changes",
|
|
63
|
+
error: "Changing password failed."
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
function G({ accountId: o, showCurrentPassword: s, onSuccess: r }) {
|
|
67
|
+
const t = Z(), m = y().userId, w = v(), { mutate: h, isPending: c, error: P } = C(q(o)), n = !w.includes("write.account.all") && !(w.includes("write.account.own") && m === o), p = c, b = U(), I = z(), O = E(), l = D({
|
|
68
|
+
initialValues: {
|
|
69
|
+
currentPassword: "",
|
|
70
|
+
newPassword: "",
|
|
71
|
+
passwordConfirmation: ""
|
|
72
|
+
},
|
|
73
|
+
validate: {
|
|
74
|
+
currentPassword: (u) => s ? b(u) : null,
|
|
75
|
+
newPassword: I,
|
|
76
|
+
passwordConfirmation: (u, { newPassword: g }) => O(u, g)
|
|
77
|
+
}
|
|
78
|
+
}), F = (u) => {
|
|
79
|
+
const g = {
|
|
80
|
+
currentPassword: s ? u.currentPassword : void 0,
|
|
81
|
+
newPassword: u.newPassword
|
|
82
|
+
};
|
|
83
|
+
h(g, {
|
|
84
|
+
onSuccess() {
|
|
85
|
+
l.reset(), r?.();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
return /* @__PURE__ */ d(i, { size: "xs", onSubmit: l.onSubmit(F), children: [
|
|
90
|
+
/* @__PURE__ */ d(i.Section, { children: [
|
|
91
|
+
P && /* @__PURE__ */ e(i.Alert, { kind: "error", title: t("error"), children: /* @__PURE__ */ e(T, { error: P }) }),
|
|
92
|
+
s && /* @__PURE__ */ e(
|
|
93
|
+
A,
|
|
94
|
+
{
|
|
95
|
+
id: "currentPassword",
|
|
96
|
+
label: t("currentPassword.label"),
|
|
97
|
+
placeholder: t("currentPassword.placeholder"),
|
|
98
|
+
description: t("currentPassword.description"),
|
|
99
|
+
readOnly: n,
|
|
100
|
+
disabled: p,
|
|
101
|
+
required: !0,
|
|
102
|
+
...l.getInputProps("currentPassword")
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ e(
|
|
106
|
+
A,
|
|
107
|
+
{
|
|
108
|
+
id: "newPassword",
|
|
109
|
+
label: t("newPassword.label"),
|
|
110
|
+
placeholder: t("newPassword.placeholder"),
|
|
111
|
+
description: t("newPassword.description"),
|
|
112
|
+
readOnly: n,
|
|
113
|
+
disabled: p,
|
|
114
|
+
required: !0,
|
|
115
|
+
...l.getInputProps("newPassword")
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ e(
|
|
119
|
+
A,
|
|
120
|
+
{
|
|
121
|
+
id: "passwordConfirmation",
|
|
122
|
+
label: t("passwordConfirmation.label"),
|
|
123
|
+
placeholder: t("passwordConfirmation.placeholder"),
|
|
124
|
+
description: t("passwordConfirmation.description"),
|
|
125
|
+
readOnly: n,
|
|
126
|
+
disabled: p,
|
|
127
|
+
required: !0,
|
|
128
|
+
...l.getInputProps("passwordConfirmation")
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
] }),
|
|
132
|
+
!n && /* @__PURE__ */ e(i.Footer, { children: /* @__PURE__ */ e(N, { type: "submit", loading: c, disabled: c || !l.isDirty(), children: t("submit") }) })
|
|
133
|
+
] });
|
|
134
|
+
}
|
|
135
|
+
const J = f("DeleteAccountForm", {
|
|
136
|
+
en: {
|
|
137
|
+
alert: {
|
|
138
|
+
title: "Danger Zone",
|
|
139
|
+
descriptionOther: "Deleting an account is irreversible. All data associated with the account will be permanently removed. Please proceed with caution.",
|
|
140
|
+
descriptionOwn: "Deleting your account is irreversible. All your data will be permanently removed and you will be logged out immediately. Please proceed with caution."
|
|
141
|
+
},
|
|
142
|
+
userName: {
|
|
143
|
+
label: "Username",
|
|
144
|
+
descriptionOwn: "Enter your account's username to proceed with deletion.",
|
|
145
|
+
descriptionOther: "Enter the account's username to proceed with deletion.",
|
|
146
|
+
placeholder: "Username",
|
|
147
|
+
mismatch: "The name must match the account's username."
|
|
148
|
+
},
|
|
149
|
+
submit: "Permanently delete account",
|
|
150
|
+
error: "Account deletion failed."
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
function K({ account: o, onSuccess: s }) {
|
|
154
|
+
const r = J(), { userId: t } = y(), m = t === o.id, { mutate: w, isPending: h, error: c } = C(x()), P = C(R()), n = D({
|
|
155
|
+
initialValues: {
|
|
156
|
+
userName: ""
|
|
157
|
+
},
|
|
158
|
+
validate: {
|
|
159
|
+
userName: (b) => b === o.userName ? null : r("userName.mismatch")
|
|
160
|
+
}
|
|
161
|
+
}), p = () => {
|
|
162
|
+
w(o.id, {
|
|
163
|
+
onSuccess() {
|
|
164
|
+
m && P.mutate(), s?.();
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
return /* @__PURE__ */ d(i, { onSubmit: n.onSubmit(p), children: [
|
|
169
|
+
/* @__PURE__ */ d(i.Section, { children: [
|
|
170
|
+
c ? /* @__PURE__ */ e(i.Alert, { kind: "error", title: r("error"), children: /* @__PURE__ */ e(T, { error: c }) }) : /* @__PURE__ */ e(M, { variant: "light", color: "red", icon: /* @__PURE__ */ e(H, { size: "1em" }), title: r("alert.title"), children: r(m ? "alert.descriptionOwn" : "alert.descriptionOther") }),
|
|
171
|
+
/* @__PURE__ */ e(
|
|
172
|
+
V,
|
|
173
|
+
{
|
|
174
|
+
id: "deleteAccountUserName",
|
|
175
|
+
label: r("userName.label"),
|
|
176
|
+
description: r(m ? "userName.descriptionOwn" : "userName.descriptionOther"),
|
|
177
|
+
placeholder: r("userName.placeholder"),
|
|
178
|
+
required: !0,
|
|
179
|
+
...n.getInputProps("userName")
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
] }),
|
|
183
|
+
/* @__PURE__ */ e(i.Footer, { children: /* @__PURE__ */ e(
|
|
184
|
+
N,
|
|
185
|
+
{
|
|
186
|
+
type: "submit",
|
|
187
|
+
color: "red",
|
|
188
|
+
leftSection: /* @__PURE__ */ e($, { size: "1em" }),
|
|
189
|
+
loading: h,
|
|
190
|
+
disabled: !n.isValid() || h,
|
|
191
|
+
children: r("submit")
|
|
192
|
+
}
|
|
193
|
+
) })
|
|
194
|
+
] });
|
|
195
|
+
}
|
|
196
|
+
export {
|
|
197
|
+
ae as C,
|
|
198
|
+
de as D,
|
|
199
|
+
ce as M
|
|
200
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { useCallback as t, useMemo as f } from "react";
|
|
2
|
+
import { isEmail as L } from "@mantine/form";
|
|
3
|
+
import { d as p } from "./i18n-ZQHvKu9t.js";
|
|
4
|
+
import { jsxs as w, Fragment as T, jsx as i } from "react/jsx-runtime";
|
|
5
|
+
import { List as l } from "@mantine/core";
|
|
6
|
+
import { ProblemDetailsError as x } from "@tiny-server/core";
|
|
7
|
+
const u = 3, m = 256, q = 6, c = 256, h = 3, d = 256, b = /^[a-zA-Z0-9-_]{3,256}$/, g = 256, v = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+", n = p("form-validators", {
|
|
8
|
+
en: {
|
|
9
|
+
required: "This field is required.",
|
|
10
|
+
userName: {
|
|
11
|
+
invalid: "The username contains invalid characters.",
|
|
12
|
+
minLength: "The username must be at least {{minLength}} characters long.",
|
|
13
|
+
maxLength: "The username must be at most {{maxLength}} characters long."
|
|
14
|
+
},
|
|
15
|
+
password: {
|
|
16
|
+
requiresLowercase: "The password must contain at least one lowercase letter.",
|
|
17
|
+
requiresUppercase: "The password must contain at least one uppercase letter.",
|
|
18
|
+
requiresDigit: "The password must contain at least one digit.",
|
|
19
|
+
requiresNonAlphanumeric: "The password must contain at least one non-alphanumeric character.",
|
|
20
|
+
minLength: "The password must be at least 6 characters long.",
|
|
21
|
+
confirmation: "The passwords do not match."
|
|
22
|
+
},
|
|
23
|
+
email: {
|
|
24
|
+
invalid: "The value must be a valid e-mail address.",
|
|
25
|
+
maxLength: "The email must be at most {{maxLength}} characters long."
|
|
26
|
+
},
|
|
27
|
+
roleName: {
|
|
28
|
+
invalid: "The role name contains invalid characters. Only alphanumeric characters, hyphens, and underscores are allowed.",
|
|
29
|
+
minLength: "The role name must be at least {{minLength}} characters long.",
|
|
30
|
+
maxLength: "The role name must be at most {{maxLength}} characters long."
|
|
31
|
+
},
|
|
32
|
+
roleDescription: {
|
|
33
|
+
maxLength: "The role description must be at most {{maxLength}} characters long."
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
function E() {
|
|
38
|
+
const e = n();
|
|
39
|
+
return t(
|
|
40
|
+
(r) => r ? null : e("required"),
|
|
41
|
+
[e]
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
function I() {
|
|
45
|
+
const e = n();
|
|
46
|
+
return t(
|
|
47
|
+
(r) => r ? [...r].some((a) => !v.includes(a)) ? e("userName.invalid") : r.length < u ? e("userName.minLength", { minLength: u }) : r.length > m ? e("userName.maxLength", { maxLength: m }) : null : e("required"),
|
|
48
|
+
[e]
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function k() {
|
|
52
|
+
const e = n();
|
|
53
|
+
return t(
|
|
54
|
+
(r) => r ? /[a-z]/.test(r) ? /[A-Z]/.test(r) ? /[0-9]/.test(r) ? /^[a-zA-Z0-9]+$/.test(r) ? e("password.requiresNonAlphanumeric") : r.length < q ? e("password.minLength") : null : e("password.requiresDigit") : e("password.requiresUppercase") : e("password.requiresLowercase") : e("required"),
|
|
55
|
+
[e]
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
function V() {
|
|
59
|
+
const e = n();
|
|
60
|
+
return t(
|
|
61
|
+
(r, a) => a ? r !== a ? e("password.confirmation") : null : e("required"),
|
|
62
|
+
[e]
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
function C() {
|
|
66
|
+
const e = n();
|
|
67
|
+
return t(
|
|
68
|
+
(r) => r ? r.length > c ? e("email.maxLength", { maxLength: c }) : L(r) ? null : e("email.invalid") : null,
|
|
69
|
+
[e]
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
function M() {
|
|
73
|
+
const e = n();
|
|
74
|
+
return t(
|
|
75
|
+
(r) => r ? r.length < h ? e("roleName.minLength", { minLength: h }) : r.length > d ? e("roleName.maxLength", { maxLength: d }) : b.test(r) ? null : e("roleName.invalid") : e("required"),
|
|
76
|
+
[e]
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
function Y() {
|
|
80
|
+
const e = n();
|
|
81
|
+
return t(
|
|
82
|
+
(r) => r && r.length > g ? e("roleDescription.maxLength", { maxLength: g }) : null,
|
|
83
|
+
[e]
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
const y = p("FormAlert", {
|
|
87
|
+
en: {
|
|
88
|
+
defaultMessage: "An unexpected error occurred. Please try again later.",
|
|
89
|
+
errors: {
|
|
90
|
+
DefaultError: "An error occurred. Please try again later.",
|
|
91
|
+
ConcurrencyFailure: "An error occurred. Please try again later.",
|
|
92
|
+
InvalidToken: "The token was invalid.",
|
|
93
|
+
RecoveryCodeRedemptionFailed: "Recovery code redemption failed.",
|
|
94
|
+
LoginAlreadyAssociated: "This external login is already associated with an account.",
|
|
95
|
+
InvalidUserName: "The user name is invalid.",
|
|
96
|
+
DuplicateUserName: "The user name is already taken by another user.",
|
|
97
|
+
InvalidEmail: "The e-mail is invalid.",
|
|
98
|
+
DuplicateEmail: "The e-mail is already taken by another user.",
|
|
99
|
+
EmailLength: "The e-mail must not exceed 256 characters.",
|
|
100
|
+
InvalidRoleName: "The role name is invalid.",
|
|
101
|
+
DuplicateRoleName: "The role exists already.",
|
|
102
|
+
UserAlreadyInRole: "User is already in the specified role.",
|
|
103
|
+
UserNotInRole: "User is not in the specified role.",
|
|
104
|
+
UserLockoutNotEnabled: "Lockout is not enabled for this user.",
|
|
105
|
+
UserAlreadyHasPassword: "User already has a password set.",
|
|
106
|
+
UserNameLength: "The user name must be between 3 and 256 characters long.",
|
|
107
|
+
PasswordMismatch: "The passwords do not match.",
|
|
108
|
+
PasswordTooShort: "Your password must be at least 6 characters long.",
|
|
109
|
+
PasswordRequiresUniqueChars: "Your password must contain at least one unique character.",
|
|
110
|
+
PasswordRequiresNonAlphanumeric: "Password must contain at least one non-alphanumeric character.",
|
|
111
|
+
PasswordRequiresDigit: "Your password must contain at least one digit.",
|
|
112
|
+
PasswordRequiresLower: "Your password must contain at least one lowercase letter.",
|
|
113
|
+
PasswordRequiresUpper: "Your password must contain at least one uppercase letter.",
|
|
114
|
+
RoleNameLength: "The role name must be between 3 and 256 characters long."
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
function F({ error: e, defaultMessage: r }) {
|
|
119
|
+
const a = y(), s = f(
|
|
120
|
+
() => e instanceof x ? Object.keys(e.problem.errors ?? {}) : [],
|
|
121
|
+
[e]
|
|
122
|
+
);
|
|
123
|
+
return /* @__PURE__ */ w(T, { children: [
|
|
124
|
+
s.length === 0 && (r ?? a("defaultMessage")),
|
|
125
|
+
s.length === 1 && a(`errors.${s[0]}`),
|
|
126
|
+
s.length > 1 && /* @__PURE__ */ i(l, { children: s.map((o) => /* @__PURE__ */ i(l.Item, { children: a(`errors.${o}`) }, o)) })
|
|
127
|
+
] });
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
F as I,
|
|
131
|
+
g as a,
|
|
132
|
+
d as b,
|
|
133
|
+
m as c,
|
|
134
|
+
V as d,
|
|
135
|
+
k as e,
|
|
136
|
+
E as f,
|
|
137
|
+
Y as g,
|
|
138
|
+
M as h,
|
|
139
|
+
I as i,
|
|
140
|
+
c as m,
|
|
141
|
+
C as u
|
|
142
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { withPermissions as t, useApp as a } from "@tiny-server/core";
|
|
3
|
+
import { U as c } from "./user-BmPfMiSO.js";
|
|
4
|
+
import { d as r } from "./i18n-ZQHvKu9t.js";
|
|
5
|
+
const i = r("ManageAccountsMenuItem", {
|
|
6
|
+
en: {
|
|
7
|
+
label: "Manage Accounts",
|
|
8
|
+
description: "Manage user accounts."
|
|
9
|
+
}
|
|
10
|
+
}), d = t(
|
|
11
|
+
{ permissions: ["read.account.all"] },
|
|
12
|
+
(n) => {
|
|
13
|
+
const e = i(), { MenuItem: s } = a().components;
|
|
14
|
+
return /* @__PURE__ */ o(
|
|
15
|
+
s,
|
|
16
|
+
{
|
|
17
|
+
label: e("label"),
|
|
18
|
+
description: e("description"),
|
|
19
|
+
to: "/manage/accounts",
|
|
20
|
+
leftSection: /* @__PURE__ */ o(c, { size: "1em" }),
|
|
21
|
+
...n
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
export {
|
|
27
|
+
d as ManageAccountsMenuItem,
|
|
28
|
+
d as default
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { withPermissions as t, useApp as a } from "@tiny-server/core";
|
|
3
|
+
import { K as i } from "./key-CmPc9vYA.js";
|
|
4
|
+
import { d as r } from "./i18n-ZQHvKu9t.js";
|
|
5
|
+
const l = r("ManageRolesMenuItem", {
|
|
6
|
+
en: {
|
|
7
|
+
label: "Manage Roles",
|
|
8
|
+
description: "Manage application roles and permissions."
|
|
9
|
+
}
|
|
10
|
+
}), u = t(
|
|
11
|
+
{ permissions: ["read.role.all"] },
|
|
12
|
+
(s) => {
|
|
13
|
+
const e = l(), { MenuItem: n } = a().components;
|
|
14
|
+
return /* @__PURE__ */ o(
|
|
15
|
+
n,
|
|
16
|
+
{
|
|
17
|
+
label: e("label"),
|
|
18
|
+
description: e("description"),
|
|
19
|
+
to: "/manage/roles",
|
|
20
|
+
leftSection: /* @__PURE__ */ o(i, { size: "1em" }),
|
|
21
|
+
...s
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
export {
|
|
27
|
+
u as ManageRolesMenuItem,
|
|
28
|
+
u as default
|
|
29
|
+
};
|