@better-auth-ui/heroui 1.6.3 → 1.6.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/components/auth/additional-field.d.ts +4 -0
- package/dist/components/auth/additional-field.js +270 -0
- package/dist/components/auth/auth-provider.d.ts +4 -6
- package/dist/components/auth/auth.d.ts +1 -1
- package/dist/components/auth/auth.js +54 -28
- package/dist/components/{settings/security → auth/delete-user}/danger-zone.d.ts +3 -4
- package/dist/components/{settings/security → auth/delete-user}/danger-zone.js +1 -1
- package/dist/components/auth/delete-user/delete-user.js +95 -0
- package/dist/components/{email → auth/email}/email-changed-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/email-changed-email.js +7 -7
- package/dist/components/{email → auth/email}/email-verification-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/email-verification-email.js +7 -7
- package/dist/components/auth/email/magic-link-email.d.ts +3 -0
- package/dist/components/{email → auth/email}/magic-link-email.js +7 -7
- package/dist/components/auth/email/new-device-email.d.ts +3 -0
- package/dist/components/{email → auth/email}/new-device-email.js +7 -7
- package/dist/components/auth/email/otp-email.d.ts +3 -0
- package/dist/components/{email → auth/email}/otp-email.js +6 -6
- package/dist/components/{email → auth/email}/password-changed-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/password-changed-email.js +7 -7
- package/dist/components/{email → auth/email}/reset-password-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/reset-password-email.js +7 -7
- package/dist/components/auth/forgot-password.d.ts +1 -1
- package/dist/components/auth/forgot-password.js +41 -38
- package/dist/components/auth/magic-link/magic-link-button.d.ts +11 -0
- package/dist/components/auth/magic-link/magic-link-button.js +20 -0
- package/dist/components/auth/magic-link/magic-link.d.ts +16 -0
- package/dist/components/auth/magic-link/magic-link.js +87 -0
- package/dist/components/{settings/account → auth/multi-session}/manage-account.d.ts +2 -6
- package/dist/components/auth/multi-session/manage-account.js +49 -0
- package/dist/components/auth/multi-session/manage-accounts.js +34 -0
- package/dist/components/{user/switch-account-menu.d.ts → auth/multi-session/switch-account-submenu-content.d.ts} +3 -3
- package/dist/components/auth/multi-session/switch-account-submenu-content.js +29 -0
- package/dist/components/{user/switch-account-item.d.ts → auth/multi-session/switch-account-submenu-item.d.ts} +2 -2
- package/dist/components/auth/multi-session/switch-account-submenu-item.js +20 -0
- package/dist/components/auth/multi-session/switch-account-submenu.d.ts +13 -0
- package/dist/components/auth/multi-session/switch-account-submenu.js +24 -0
- package/dist/components/auth/passkey/passkey-button.d.ts +6 -0
- package/dist/components/auth/passkey/passkey-button.js +24 -0
- package/dist/components/auth/passkey/passkey.js +45 -0
- package/dist/components/auth/passkey/passkeys.js +106 -0
- package/dist/components/auth/provider-button.d.ts +6 -8
- package/dist/components/auth/provider-button.js +16 -20
- package/dist/components/auth/provider-buttons.d.ts +3 -4
- package/dist/components/auth/provider-buttons.js +9 -10
- package/dist/components/auth/reset-password.js +110 -107
- package/dist/components/{settings → auth/settings}/account/account-settings.d.ts +5 -2
- package/dist/components/auth/settings/account/account-settings.js +20 -0
- package/dist/components/auth/settings/account/change-avatar.js +89 -0
- package/dist/components/{settings → auth/settings}/account/change-email.js +17 -17
- package/dist/components/{settings → auth/settings}/account/user-profile.d.ts +2 -3
- package/dist/components/auth/settings/account/user-profile.js +86 -0
- package/dist/components/auth/settings/security/active-session.js +59 -0
- package/dist/components/{settings → auth/settings}/security/active-sessions.js +4 -4
- package/dist/components/auth/settings/security/change-password.js +189 -0
- package/dist/components/auth/settings/security/linked-account.js +56 -0
- package/dist/components/{settings → auth/settings}/security/linked-accounts.js +5 -5
- package/dist/components/{settings → auth/settings}/security/security-settings.d.ts +1 -1
- package/dist/components/auth/settings/security/security-settings.js +22 -0
- package/dist/components/auth/settings/settings.js +45 -0
- package/dist/components/auth/sign-in.js +75 -99
- package/dist/components/auth/sign-out.js +11 -11
- package/dist/components/auth/sign-up.js +123 -148
- package/dist/components/{settings/account → auth/theme}/appearance.d.ts +3 -6
- package/dist/components/auth/theme/appearance.js +72 -0
- package/dist/components/auth/theme/theme-toggle-item.d.ts +5 -0
- package/dist/components/auth/theme/theme-toggle-item.js +58 -0
- package/dist/components/auth/user/user-avatar.js +29 -0
- package/dist/components/{user → auth/user}/user-button.d.ts +2 -6
- package/dist/components/auth/user/user-button.js +55 -0
- package/dist/components/auth/user/user-view.js +37 -0
- package/dist/components/auth/username/sign-in-username.d.ts +14 -0
- package/dist/components/auth/username/sign-in-username.js +142 -0
- package/dist/components/auth/username/username-field.d.ts +8 -0
- package/dist/components/auth/username/username-field.js +51 -0
- package/dist/email.d.ts +7 -0
- package/dist/email.js +9 -0
- package/dist/index.d.ts +12 -27
- package/dist/index.js +20 -35
- package/dist/lib/auth/auth-plugin.d.ts +44 -0
- package/dist/lib/auth/delete-user-plugin.d.ts +17 -0
- package/dist/lib/auth/delete-user-plugin.js +10 -0
- package/dist/lib/auth/magic-link-plugin.d.ts +31 -0
- package/dist/lib/auth/magic-link-plugin.js +13 -0
- package/dist/lib/auth/multi-session-plugin.d.ts +18 -0
- package/dist/lib/auth/multi-session-plugin.js +12 -0
- package/dist/lib/auth/passkey-plugin.d.ts +20 -0
- package/dist/lib/auth/passkey-plugin.js +12 -0
- package/dist/lib/auth/theme-plugin.d.ts +68 -0
- package/dist/lib/auth/theme-plugin.js +23 -0
- package/dist/lib/auth/username-plugin.d.ts +63 -0
- package/dist/lib/auth/username-plugin.js +18 -0
- package/dist/plugins.d.ts +20 -0
- package/dist/plugins.js +21 -0
- package/package.json +19 -21
- package/src/components/auth/additional-field.tsx +554 -0
- package/src/components/auth/auth-provider.tsx +5 -6
- package/src/components/auth/auth.tsx +99 -35
- package/src/components/{settings/security → auth/delete-user}/danger-zone.tsx +3 -10
- package/src/components/{settings/security → auth/delete-user}/delete-user.tsx +30 -20
- package/src/components/{email → auth/email}/email-changed-email.tsx +2 -2
- package/src/components/{email → auth/email}/email-verification-email.tsx +2 -2
- package/src/components/{email → auth/email}/magic-link-email.tsx +2 -2
- package/src/components/{email → auth/email}/new-device-email.tsx +2 -2
- package/src/components/{email → auth/email}/otp-email.tsx +2 -2
- package/src/components/{email → auth/email}/password-changed-email.tsx +2 -2
- package/src/components/{email → auth/email}/reset-password-email.tsx +2 -2
- package/src/components/auth/forgot-password.tsx +14 -11
- package/src/components/auth/magic-link/magic-link-button.tsx +61 -0
- package/src/components/auth/{magic-link.tsx → magic-link/magic-link.tsx} +55 -40
- package/src/components/{settings/account → auth/multi-session}/manage-account.tsx +16 -13
- package/src/components/{settings/account → auth/multi-session}/manage-accounts.tsx +14 -5
- package/src/components/{user/switch-account-menu.tsx → auth/multi-session/switch-account-submenu-content.tsx} +18 -11
- package/src/components/{user/switch-account-item.tsx → auth/multi-session/switch-account-submenu-item.tsx} +17 -5
- package/src/components/auth/multi-session/switch-account-submenu.tsx +50 -0
- package/src/components/auth/passkey/passkey-button.tsx +56 -0
- package/src/components/{settings/security → auth/passkey}/passkey.tsx +20 -6
- package/src/components/auth/passkey/passkeys.tsx +196 -0
- package/src/components/auth/provider-button.tsx +27 -29
- package/src/components/auth/provider-buttons.tsx +6 -11
- package/src/components/auth/reset-password.tsx +13 -7
- package/src/components/{settings → auth/settings}/account/account-settings.tsx +15 -13
- package/src/components/{settings → auth/settings}/account/change-avatar.tsx +4 -3
- package/src/components/{settings → auth/settings}/account/change-email.tsx +3 -3
- package/src/components/auth/settings/account/user-profile.tsx +171 -0
- package/src/components/{settings → auth/settings}/security/active-session.tsx +8 -5
- package/src/components/{settings → auth/settings}/security/active-sessions.tsx +3 -3
- package/src/components/{settings → auth/settings}/security/change-password.tsx +14 -9
- package/src/components/{settings → auth/settings}/security/linked-account.tsx +12 -8
- package/src/components/{settings → auth/settings}/security/linked-accounts.tsx +2 -2
- package/src/components/{settings → auth/settings}/security/security-settings.tsx +7 -6
- package/src/components/{settings → auth/settings}/settings.tsx +2 -2
- package/src/components/auth/sign-in.tsx +38 -61
- package/src/components/auth/sign-out.tsx +2 -2
- package/src/components/auth/sign-up.tsx +109 -131
- package/src/components/{settings/account → auth/theme}/appearance.tsx +17 -24
- package/src/components/auth/theme/theme-toggle-item.tsx +110 -0
- package/src/components/{user → auth/user}/user-avatar.tsx +12 -4
- package/src/components/{user → auth/user}/user-button.tsx +15 -88
- package/src/components/{user → auth/user}/user-view.tsx +12 -4
- package/src/components/auth/username/sign-in-username.tsx +283 -0
- package/src/components/auth/username/username-field.tsx +122 -0
- package/src/email.ts +9 -0
- package/src/index.tsx +12 -27
- package/src/lib/auth/auth-plugin.ts +67 -0
- package/src/lib/auth/delete-user-plugin.ts +15 -0
- package/src/lib/auth/magic-link-plugin.ts +26 -0
- package/src/lib/auth/multi-session-plugin.ts +17 -0
- package/src/lib/auth/passkey-plugin.ts +17 -0
- package/src/lib/auth/theme-plugin.ts +86 -0
- package/src/lib/auth/username-plugin.tsx +30 -0
- package/src/plugins.ts +23 -0
- package/dist/components/auth/magic-link-button.d.ts +0 -13
- package/dist/components/auth/magic-link-button.js +0 -16
- package/dist/components/auth/magic-link.d.ts +0 -17
- package/dist/components/auth/magic-link.js +0 -99
- package/dist/components/auth/passkey-button.d.ts +0 -4
- package/dist/components/auth/passkey-button.js +0 -21
- package/dist/components/email/magic-link-email.d.ts +0 -3
- package/dist/components/email/new-device-email.d.ts +0 -3
- package/dist/components/email/otp-email.d.ts +0 -3
- package/dist/components/settings/account/account-settings.js +0 -23
- package/dist/components/settings/account/appearance.js +0 -71
- package/dist/components/settings/account/change-avatar.js +0 -89
- package/dist/components/settings/account/manage-account.js +0 -48
- package/dist/components/settings/account/manage-accounts.js +0 -33
- package/dist/components/settings/account/user-profile.js +0 -103
- package/dist/components/settings/security/active-session.js +0 -59
- package/dist/components/settings/security/change-password.js +0 -189
- package/dist/components/settings/security/delete-user.js +0 -92
- package/dist/components/settings/security/linked-account.js +0 -56
- package/dist/components/settings/security/passkey.js +0 -43
- package/dist/components/settings/security/passkeys.js +0 -53
- package/dist/components/settings/security/security-settings.js +0 -25
- package/dist/components/settings/settings.js +0 -45
- package/dist/components/user/switch-account-item.js +0 -20
- package/dist/components/user/switch-account-menu.js +0 -28
- package/dist/components/user/user-avatar.js +0 -29
- package/dist/components/user/user-button.js +0 -91
- package/dist/components/user/user-view.js +0 -37
- package/dist/core.d.ts +0 -1
- package/dist/core.js +0 -1
- package/dist/react-exports.d.ts +0 -1
- package/dist/react-exports.js +0 -1
- package/src/components/auth/magic-link-button.tsx +0 -43
- package/src/components/auth/passkey-button.tsx +0 -35
- package/src/components/settings/account/user-profile.tsx +0 -217
- package/src/components/settings/security/passkeys.tsx +0 -96
- package/src/core.ts +0 -1
- package/src/react-exports.ts +0 -1
- /package/dist/components/{settings/security → auth/delete-user}/delete-user.d.ts +0 -0
- /package/dist/components/{settings/account → auth/multi-session}/manage-accounts.d.ts +0 -0
- /package/dist/components/{settings/security → auth/passkey}/passkey.d.ts +0 -0
- /package/dist/components/{settings/security → auth/passkey}/passkeys.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/account/change-avatar.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/account/change-email.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/active-session.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/active-sessions.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/change-password.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/linked-account.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/linked-accounts.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/settings.d.ts +0 -0
- /package/dist/components/{user → auth/user}/user-avatar.d.ts +0 -0
- /package/dist/components/{user → auth/user}/user-view.d.ts +0 -0
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { UserAvatar as e } from "../../user/user-avatar.js";
|
|
2
|
-
import { useAuth as t, useSession as n, useUpdateUser as r } from "@better-auth-ui/react";
|
|
3
|
-
import { Button as i, Dropdown as a, Label as o, Spinner as s, cn as c, toast as l } from "@heroui/react";
|
|
4
|
-
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
5
|
-
import { useRef as f, useState as p } from "react";
|
|
6
|
-
import { CloudArrowUpIn as m, TrashBin as h } from "@gravity-ui/icons";
|
|
7
|
-
import { fileToBase64 as g } from "@better-auth-ui/core";
|
|
8
|
-
//#region src/components/settings/account/change-avatar.tsx
|
|
9
|
-
function _({ className: _ }) {
|
|
10
|
-
let { localization: v, avatar: y } = t(), { data: b } = n(), { mutate: x, isPending: S } = r(), C = f(null), [w, T] = p(!1), [E, D] = p(!1), O = S || w || E;
|
|
11
|
-
async function k(e) {
|
|
12
|
-
let t = e.target.files?.[0];
|
|
13
|
-
if (t) {
|
|
14
|
-
e.target.value = "", T(!0);
|
|
15
|
-
try {
|
|
16
|
-
let e = await y.resize?.(t, y.size, y.extension) || t;
|
|
17
|
-
x({ image: await y.upload?.(e) || await g(e) }, { onSuccess: () => l.success(v.settings.avatarChangedSuccess) });
|
|
18
|
-
} catch (e) {
|
|
19
|
-
e instanceof Error && l.danger(e.message);
|
|
20
|
-
}
|
|
21
|
-
T(!1);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async function A() {
|
|
25
|
-
let e = b?.user.image;
|
|
26
|
-
x({ image: null }, { onSuccess: async () => {
|
|
27
|
-
if (e) {
|
|
28
|
-
D(!0);
|
|
29
|
-
try {
|
|
30
|
-
await y.delete?.(e);
|
|
31
|
-
} finally {
|
|
32
|
-
D(!1);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
l.success(v.settings.avatarDeletedSuccess);
|
|
36
|
-
} });
|
|
37
|
-
}
|
|
38
|
-
return /* @__PURE__ */ d("div", {
|
|
39
|
-
className: c("flex flex-col gap-1", _),
|
|
40
|
-
children: [
|
|
41
|
-
/* @__PURE__ */ u(o, {
|
|
42
|
-
isDisabled: !b,
|
|
43
|
-
children: v.settings.avatar
|
|
44
|
-
}),
|
|
45
|
-
/* @__PURE__ */ u("input", {
|
|
46
|
-
ref: C,
|
|
47
|
-
type: "file",
|
|
48
|
-
accept: "image/*",
|
|
49
|
-
className: "hidden",
|
|
50
|
-
onChange: k
|
|
51
|
-
}),
|
|
52
|
-
/* @__PURE__ */ d("div", {
|
|
53
|
-
className: "flex items-center gap-4",
|
|
54
|
-
children: [/* @__PURE__ */ u(i, {
|
|
55
|
-
type: "button",
|
|
56
|
-
isIconOnly: !0,
|
|
57
|
-
variant: "ghost",
|
|
58
|
-
className: "p-0 h-auto w-auto rounded-full",
|
|
59
|
-
isDisabled: !b || O,
|
|
60
|
-
onPress: () => C.current?.click(),
|
|
61
|
-
children: /* @__PURE__ */ u(e, {
|
|
62
|
-
size: "lg",
|
|
63
|
-
isPending: O
|
|
64
|
-
})
|
|
65
|
-
}), /* @__PURE__ */ d(a, { children: [/* @__PURE__ */ d(i, {
|
|
66
|
-
isDisabled: !b || O,
|
|
67
|
-
size: "sm",
|
|
68
|
-
variant: "secondary",
|
|
69
|
-
children: [O && /* @__PURE__ */ u(s, { size: "sm" }), v.settings.changeAvatar]
|
|
70
|
-
}), /* @__PURE__ */ u(a.Popover, {
|
|
71
|
-
className: "min-w-fit",
|
|
72
|
-
children: /* @__PURE__ */ d(a.Menu, { children: [/* @__PURE__ */ d(a.Item, {
|
|
73
|
-
textValue: v.settings.uploadAvatar,
|
|
74
|
-
onAction: () => C.current?.click(),
|
|
75
|
-
children: [/* @__PURE__ */ u(m, { className: "text-muted" }), /* @__PURE__ */ u(o, { children: v.settings.uploadAvatar })]
|
|
76
|
-
}), /* @__PURE__ */ d(a.Item, {
|
|
77
|
-
textValue: v.settings.deleteAvatar,
|
|
78
|
-
isDisabled: !b?.user.image,
|
|
79
|
-
onAction: A,
|
|
80
|
-
variant: "danger",
|
|
81
|
-
children: [/* @__PURE__ */ u(h, { className: "text-danger" }), /* @__PURE__ */ u(o, { children: v.settings.deleteAvatar })]
|
|
82
|
-
})] })
|
|
83
|
-
})] })]
|
|
84
|
-
})
|
|
85
|
-
]
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
|
-
export { _ as ChangeAvatar };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { UserView as e } from "../../user/user-view.js";
|
|
2
|
-
import { useAuth as t, useRevokeMultiSession as n, useSetActiveSession as r, useUser as i } from "@better-auth-ui/react";
|
|
3
|
-
import { Button as a, Dropdown as o, Spinner as s, toast as c } from "@heroui/react";
|
|
4
|
-
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
5
|
-
import { ArrowRightArrowLeft as d, ArrowRightFromSquare as f, Ellipsis as p } from "@gravity-ui/icons";
|
|
6
|
-
//#region src/components/settings/account/manage-account.tsx
|
|
7
|
-
function m({ deviceSession: m, isPending: h }) {
|
|
8
|
-
let { localization: g } = t(), { data: _ } = i(), { mutate: v, isPending: y } = r(), { mutate: b, isPending: x } = n({ onSuccess: () => c.success(g.settings.revokeSessionSuccess) }), S = m?.session.userId === _?.id, C = y || x;
|
|
9
|
-
return /* @__PURE__ */ u("div", {
|
|
10
|
-
className: "flex items-center justify-between gap-3",
|
|
11
|
-
children: [
|
|
12
|
-
/* @__PURE__ */ l(e, {
|
|
13
|
-
user: m?.user,
|
|
14
|
-
isPending: h,
|
|
15
|
-
size: "md"
|
|
16
|
-
}),
|
|
17
|
-
m && S && /* @__PURE__ */ u(a, {
|
|
18
|
-
className: "shrink-0",
|
|
19
|
-
variant: "outline",
|
|
20
|
-
size: "sm",
|
|
21
|
-
onPress: () => b({ sessionToken: m.session.token }),
|
|
22
|
-
isDisabled: C,
|
|
23
|
-
children: [x ? /* @__PURE__ */ l(s, {
|
|
24
|
-
color: "current",
|
|
25
|
-
size: "sm"
|
|
26
|
-
}) : /* @__PURE__ */ l(f, {}), g.auth.signOut]
|
|
27
|
-
}),
|
|
28
|
-
m && !S && /* @__PURE__ */ u(o, { children: [/* @__PURE__ */ l(a, {
|
|
29
|
-
isIconOnly: !0,
|
|
30
|
-
variant: "ghost",
|
|
31
|
-
className: "shrink-0",
|
|
32
|
-
size: "sm",
|
|
33
|
-
isDisabled: C,
|
|
34
|
-
children: /* @__PURE__ */ l(p, {})
|
|
35
|
-
}), /* @__PURE__ */ l(o.Popover, { children: /* @__PURE__ */ u(o.Menu, { children: [/* @__PURE__ */ u(o.Item, {
|
|
36
|
-
textValue: g.auth.switchAccount,
|
|
37
|
-
onAction: () => v({ sessionToken: m.session.token }),
|
|
38
|
-
children: [/* @__PURE__ */ l(d, { className: "text-muted" }), g.auth.switchAccount]
|
|
39
|
-
}), /* @__PURE__ */ u(o.Item, {
|
|
40
|
-
textValue: g.auth.signOut,
|
|
41
|
-
onAction: () => b({ sessionToken: m.session.token }),
|
|
42
|
-
children: [/* @__PURE__ */ l(f, { className: "text-muted" }), g.auth.signOut]
|
|
43
|
-
})] }) })] })
|
|
44
|
-
]
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
export { m as ManageAccount };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ManageAccount as e } from "./manage-account.js";
|
|
2
|
-
import { useAuth as t, useListDeviceSessions as n, useSession as r } from "@better-auth-ui/react";
|
|
3
|
-
import { Card as i, cn as a } from "@heroui/react";
|
|
4
|
-
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
-
//#region src/components/settings/account/manage-accounts.tsx
|
|
6
|
-
function c({ className: c, variant: l, ...u }) {
|
|
7
|
-
let { localization: d } = t(), { data: f } = r(), { data: p, isPending: m } = n(), h = p?.filter((e) => e.session.id !== f?.session.id), g = [{
|
|
8
|
-
key: "current",
|
|
9
|
-
deviceSession: m ? null : f,
|
|
10
|
-
isPending: m
|
|
11
|
-
}, ...h?.map((e) => ({
|
|
12
|
-
key: e.session.id,
|
|
13
|
-
deviceSession: e,
|
|
14
|
-
isPending: !1
|
|
15
|
-
})) ?? []];
|
|
16
|
-
return /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("h2", {
|
|
17
|
-
className: a("text-sm font-semibold mb-3"),
|
|
18
|
-
children: d.settings.manageAccounts
|
|
19
|
-
}), /* @__PURE__ */ o(i, {
|
|
20
|
-
className: a(c),
|
|
21
|
-
variant: l,
|
|
22
|
-
...u,
|
|
23
|
-
children: /* @__PURE__ */ o(i.Content, {
|
|
24
|
-
className: "gap-0",
|
|
25
|
-
children: g.map((t, n) => /* @__PURE__ */ s("div", { children: [n > 0 && /* @__PURE__ */ o("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ o(e, {
|
|
26
|
-
deviceSession: t.deviceSession,
|
|
27
|
-
isPending: t.isPending
|
|
28
|
-
})] }, t.key))
|
|
29
|
-
})
|
|
30
|
-
})] });
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { c as ManageAccounts };
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { ChangeAvatar as e } from "./change-avatar.js";
|
|
2
|
-
import { useAuth as t, useIsUsernameAvailable as n, useSession as r, useUpdateUser as i } from "@better-auth-ui/react";
|
|
3
|
-
import { Button as a, Card as o, FieldError as s, Fieldset as c, Form as l, Input as u, InputGroup as d, Label as f, Skeleton as p, Spinner as m, TextField as h, cn as g, toast as _ } from "@heroui/react";
|
|
4
|
-
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
5
|
-
import { useEffect as b, useState as x } from "react";
|
|
6
|
-
import { Check as S, Xmark as C } from "@gravity-ui/icons";
|
|
7
|
-
import { useDebouncer as w } from "@tanstack/react-pacer";
|
|
8
|
-
//#region src/components/settings/account/user-profile.tsx
|
|
9
|
-
function T({ className: T, variant: E, ...D }) {
|
|
10
|
-
let { localization: O, username: k } = t(), { data: A } = r(), j = (k?.displayUsername ? A?.user?.displayUsername : A?.user?.username) || "", [M, N] = x(j);
|
|
11
|
-
b(() => {
|
|
12
|
-
N(j);
|
|
13
|
-
}, [j]);
|
|
14
|
-
let { mutate: P, data: F, error: I, reset: L } = n(), R = w((e) => {
|
|
15
|
-
if (!e.trim() || e.trim() === j) {
|
|
16
|
-
L();
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
P({ username: e.trim() });
|
|
20
|
-
}, { wait: 500 });
|
|
21
|
-
function z(e) {
|
|
22
|
-
N(e), L(), k?.isUsernameAvailable && R.maybeExecute(e);
|
|
23
|
-
}
|
|
24
|
-
let { mutate: B, isPending: V } = i({ onSuccess: () => _.success(O.settings.profileUpdatedSuccess) });
|
|
25
|
-
function H(e) {
|
|
26
|
-
e.preventDefault(), B({
|
|
27
|
-
name: new FormData(e.currentTarget).get("name"),
|
|
28
|
-
...k?.enabled ? {
|
|
29
|
-
username: M.trim(),
|
|
30
|
-
...k.displayUsername ? { displayUsername: M.trim() } : {}
|
|
31
|
-
} : {}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("h2", {
|
|
35
|
-
className: g("text-sm font-semibold mb-3"),
|
|
36
|
-
children: O.settings.profile
|
|
37
|
-
}), /* @__PURE__ */ v(o, {
|
|
38
|
-
className: g("p-4 gap-4", T),
|
|
39
|
-
variant: E,
|
|
40
|
-
...D,
|
|
41
|
-
children: /* @__PURE__ */ v(o.Content, { children: /* @__PURE__ */ v(l, {
|
|
42
|
-
onSubmit: H,
|
|
43
|
-
children: /* @__PURE__ */ y(c, {
|
|
44
|
-
className: "w-full gap-4",
|
|
45
|
-
children: [
|
|
46
|
-
/* @__PURE__ */ v(e, {}),
|
|
47
|
-
/* @__PURE__ */ y(c.Group, { children: [k?.enabled && /* @__PURE__ */ y(h, {
|
|
48
|
-
type: "text",
|
|
49
|
-
autoComplete: "username",
|
|
50
|
-
minLength: k.minUsernameLength,
|
|
51
|
-
maxLength: k.maxUsernameLength,
|
|
52
|
-
isDisabled: V || !A,
|
|
53
|
-
value: M,
|
|
54
|
-
onChange: z,
|
|
55
|
-
isInvalid: !!I || F && !F.available,
|
|
56
|
-
children: [
|
|
57
|
-
/* @__PURE__ */ v(f, { children: O.auth.username }),
|
|
58
|
-
A ? /* @__PURE__ */ y(d, {
|
|
59
|
-
variant: E === "transparent" ? "primary" : "secondary",
|
|
60
|
-
children: [/* @__PURE__ */ v(d.Input, {
|
|
61
|
-
placeholder: O.auth.usernamePlaceholder,
|
|
62
|
-
name: "username"
|
|
63
|
-
}), k.isUsernameAvailable && M.trim() && M.trim() !== j && /* @__PURE__ */ v(d.Suffix, {
|
|
64
|
-
className: "px-2",
|
|
65
|
-
children: F?.available ? /* @__PURE__ */ v(S, { className: "text-success" }) : I || F?.available === !1 ? /* @__PURE__ */ v(C, { className: "text-danger" }) : /* @__PURE__ */ v(m, {
|
|
66
|
-
size: "sm",
|
|
67
|
-
color: "current"
|
|
68
|
-
})
|
|
69
|
-
})]
|
|
70
|
-
}) : /* @__PURE__ */ v(p, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
71
|
-
/* @__PURE__ */ v(s, { children: I?.error?.message || I?.message || F?.available === !1 && O.auth.usernameTaken })
|
|
72
|
-
]
|
|
73
|
-
}), /* @__PURE__ */ y(h, {
|
|
74
|
-
name: "name",
|
|
75
|
-
defaultValue: A?.user.name,
|
|
76
|
-
isDisabled: V || !A,
|
|
77
|
-
children: [
|
|
78
|
-
/* @__PURE__ */ v(f, { children: O.auth.name }),
|
|
79
|
-
A ? /* @__PURE__ */ v(u, {
|
|
80
|
-
autoComplete: "name",
|
|
81
|
-
placeholder: O.auth.name,
|
|
82
|
-
variant: E === "transparent" ? "primary" : "secondary"
|
|
83
|
-
}) : /* @__PURE__ */ v(p, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
84
|
-
/* @__PURE__ */ v(s, {})
|
|
85
|
-
]
|
|
86
|
-
}, A?.user?.name)] }),
|
|
87
|
-
/* @__PURE__ */ v(c.Actions, { children: /* @__PURE__ */ y(a, {
|
|
88
|
-
type: "submit",
|
|
89
|
-
isPending: V,
|
|
90
|
-
isDisabled: !A,
|
|
91
|
-
size: "sm",
|
|
92
|
-
children: [V && /* @__PURE__ */ v(m, {
|
|
93
|
-
color: "current",
|
|
94
|
-
size: "sm"
|
|
95
|
-
}), O.settings.saveChanges]
|
|
96
|
-
}) })
|
|
97
|
-
]
|
|
98
|
-
})
|
|
99
|
-
}) })
|
|
100
|
-
})] });
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
|
-
export { T as UserProfile };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { useAuth as e, useRevokeSession as t, useSession as n } from "@better-auth-ui/react";
|
|
2
|
-
import { Button as r, Chip as i, Spinner as a, toast as o } from "@heroui/react";
|
|
3
|
-
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
4
|
-
import { ArrowRightFromSquare as l, Display as u, Smartphone as d, Xmark as f } from "@gravity-ui/icons";
|
|
5
|
-
import p from "bowser";
|
|
6
|
-
//#region src/components/settings/security/active-session.tsx
|
|
7
|
-
function m(e) {
|
|
8
|
-
let t = Math.floor((Date.now() - e.getTime()) / 1e3), n = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
|
|
9
|
-
for (let [e, r] of [
|
|
10
|
-
["year", 31536e3],
|
|
11
|
-
["month", 2592e3],
|
|
12
|
-
["week", 604800],
|
|
13
|
-
["day", 86400],
|
|
14
|
-
["hour", 3600],
|
|
15
|
-
["minute", 60],
|
|
16
|
-
["second", 1]
|
|
17
|
-
]) if (t >= r) return n.format(-Math.floor(t / r), e);
|
|
18
|
-
return n.format(0, "second");
|
|
19
|
-
}
|
|
20
|
-
function h({ activeSession: h }) {
|
|
21
|
-
let { basePaths: g, localization: _, viewPaths: v, navigate: y } = e(), { data: b } = n({ refetchOnMount: !1 }), { mutate: x, isPending: S } = t({ onSuccess: () => o.success(_.settings.revokeSessionSuccess) }), C = h.token === b?.session.token, w = p.parse(h.userAgent || "");
|
|
22
|
-
return /* @__PURE__ */ c("div", {
|
|
23
|
-
className: "flex items-center gap-3",
|
|
24
|
-
children: [
|
|
25
|
-
/* @__PURE__ */ s("div", {
|
|
26
|
-
className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary",
|
|
27
|
-
children: w.platform.type === "mobile" || w.platform.type === "tablet" ? /* @__PURE__ */ s(d, { className: "size-4.5" }) : /* @__PURE__ */ s(u, { className: "size-4.5" })
|
|
28
|
-
}),
|
|
29
|
-
/* @__PURE__ */ c("div", {
|
|
30
|
-
className: "flex flex-col min-w-0",
|
|
31
|
-
children: [/* @__PURE__ */ c("span", {
|
|
32
|
-
className: "text-sm font-medium truncate",
|
|
33
|
-
children: [w.browser.name || "Unknown Browser", w.os.name ? `, ${w.os.name}` : ""]
|
|
34
|
-
}), C ? /* @__PURE__ */ s(i, {
|
|
35
|
-
color: "accent",
|
|
36
|
-
size: "sm",
|
|
37
|
-
children: _.settings.currentSession
|
|
38
|
-
}) : h.createdAt && /* @__PURE__ */ s("span", {
|
|
39
|
-
className: "text-xs text-muted capitalize",
|
|
40
|
-
children: m(h.createdAt)
|
|
41
|
-
})]
|
|
42
|
-
}),
|
|
43
|
-
/* @__PURE__ */ c(r, {
|
|
44
|
-
className: "ml-auto shrink-0",
|
|
45
|
-
variant: "outline",
|
|
46
|
-
size: "sm",
|
|
47
|
-
onPress: () => C ? y({ to: `${g.auth}/${v.auth.signOut}` }) : x(h),
|
|
48
|
-
isPending: S,
|
|
49
|
-
"aria-label": C ? _.auth.signOut : _.settings.revokeSession,
|
|
50
|
-
children: [S ? /* @__PURE__ */ s(a, {
|
|
51
|
-
color: "current",
|
|
52
|
-
size: "sm"
|
|
53
|
-
}) : s(C ? l : f, {}), C ? _.auth.signOut : _.settings.revoke]
|
|
54
|
-
})
|
|
55
|
-
]
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
export { h as ActiveSession };
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { useAuth as e, useChangePassword as t, useListAccounts as n, useRequestPasswordReset as r, useSession as i } from "@better-auth-ui/react";
|
|
2
|
-
import { Button as a, Card as o, FieldError as s, Fieldset as c, Form as l, Input as u, InputGroup as d, Label as f, Skeleton as p, Spinner as m, TextField as h, cn as g, toast as _ } from "@heroui/react";
|
|
3
|
-
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
4
|
-
import { useState as b } from "react";
|
|
5
|
-
import { Eye as x, EyeSlash as S } from "@gravity-ui/icons";
|
|
6
|
-
//#region src/components/settings/security/change-password.tsx
|
|
7
|
-
function C({ className: t, variant: r, ...a }) {
|
|
8
|
-
let { emailAndPassword: o, localization: s } = e(), { data: c } = i(), { data: l, isPending: u } = n(), d = l?.some((e) => e.providerId === "credential");
|
|
9
|
-
return !u && !d ? /* @__PURE__ */ v(w, {
|
|
10
|
-
className: t,
|
|
11
|
-
variant: r,
|
|
12
|
-
...a
|
|
13
|
-
}) : /* @__PURE__ */ v(T, {
|
|
14
|
-
className: t,
|
|
15
|
-
variant: r,
|
|
16
|
-
emailAndPassword: o,
|
|
17
|
-
localization: s,
|
|
18
|
-
session: u ? void 0 : c,
|
|
19
|
-
...a
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function w({ className: t, variant: n, ...s }) {
|
|
23
|
-
let { localization: c } = e(), { data: l } = i(), { mutate: u, isPending: d } = r({ onSuccess: () => _.success(c.auth.passwordResetEmailSent) }), f = () => {
|
|
24
|
-
l?.user.email && u({ email: l.user.email });
|
|
25
|
-
};
|
|
26
|
-
return /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("h2", {
|
|
27
|
-
className: g("text-sm font-semibold mb-3"),
|
|
28
|
-
children: c.settings.changePassword
|
|
29
|
-
}), /* @__PURE__ */ v(o, {
|
|
30
|
-
className: g(t),
|
|
31
|
-
variant: n,
|
|
32
|
-
...s,
|
|
33
|
-
children: /* @__PURE__ */ y(o.Content, {
|
|
34
|
-
className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
35
|
-
children: [/* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("p", {
|
|
36
|
-
className: "text-sm font-medium leading-tight",
|
|
37
|
-
children: c.settings.setPassword
|
|
38
|
-
}), /* @__PURE__ */ v("p", {
|
|
39
|
-
className: "text-muted text-xs mt-0.5",
|
|
40
|
-
children: c.settings.setPasswordDescription
|
|
41
|
-
})] }), /* @__PURE__ */ y(a, {
|
|
42
|
-
size: "sm",
|
|
43
|
-
isPending: d,
|
|
44
|
-
isDisabled: !l,
|
|
45
|
-
onPress: f,
|
|
46
|
-
children: [d && /* @__PURE__ */ v(m, {
|
|
47
|
-
color: "current",
|
|
48
|
-
size: "sm"
|
|
49
|
-
}), c.auth.sendResetLink]
|
|
50
|
-
})]
|
|
51
|
-
})
|
|
52
|
-
})] });
|
|
53
|
-
}
|
|
54
|
-
function T({ className: e, variant: n, emailAndPassword: r, localization: i, session: C, ...w }) {
|
|
55
|
-
let [T, E] = b(""), [D, O] = b(""), [k, A] = b(""), { mutate: j, isPending: M } = t({
|
|
56
|
-
onError: (e) => {
|
|
57
|
-
E(""), O(""), A(""), _.danger(e.error?.message || e.message);
|
|
58
|
-
},
|
|
59
|
-
onSuccess: () => {
|
|
60
|
-
E(""), O(""), A(""), _.success(i.settings.changePasswordSuccess);
|
|
61
|
-
}
|
|
62
|
-
}), [N, P] = b(!1), [F, I] = b(!1), L = (e) => {
|
|
63
|
-
if (e.preventDefault(), r?.confirmPassword && D !== k) {
|
|
64
|
-
E(""), O(""), A(""), _.danger(i.auth.passwordsDoNotMatch);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
j({
|
|
68
|
-
currentPassword: T,
|
|
69
|
-
newPassword: D,
|
|
70
|
-
revokeOtherSessions: !0
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
return /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("h2", {
|
|
74
|
-
className: g("text-sm font-semibold mb-3"),
|
|
75
|
-
children: i.settings.changePassword
|
|
76
|
-
}), /* @__PURE__ */ v(o, {
|
|
77
|
-
className: g("p-4 gap-4", e),
|
|
78
|
-
variant: n,
|
|
79
|
-
...w,
|
|
80
|
-
children: /* @__PURE__ */ v(o.Content, { children: /* @__PURE__ */ v(l, {
|
|
81
|
-
onSubmit: L,
|
|
82
|
-
children: /* @__PURE__ */ y(c, {
|
|
83
|
-
className: "w-full gap-4",
|
|
84
|
-
children: [/* @__PURE__ */ y(c.Group, { children: [
|
|
85
|
-
/* @__PURE__ */ y(h, {
|
|
86
|
-
name: "currentPassword",
|
|
87
|
-
type: "password",
|
|
88
|
-
isDisabled: M || !C,
|
|
89
|
-
defaultValue: "",
|
|
90
|
-
value: T,
|
|
91
|
-
onChange: E,
|
|
92
|
-
children: [
|
|
93
|
-
/* @__PURE__ */ v(f, { children: i.settings.currentPassword }),
|
|
94
|
-
/* @__PURE__ */ v(u, {
|
|
95
|
-
className: g(!C && "hidden"),
|
|
96
|
-
autoComplete: "current-password",
|
|
97
|
-
placeholder: i.settings.currentPasswordPlaceholder,
|
|
98
|
-
required: !0,
|
|
99
|
-
variant: n === "transparent" ? "primary" : "secondary"
|
|
100
|
-
}),
|
|
101
|
-
!C && /* @__PURE__ */ v(p, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
102
|
-
/* @__PURE__ */ v(s, {})
|
|
103
|
-
]
|
|
104
|
-
}),
|
|
105
|
-
/* @__PURE__ */ y(h, {
|
|
106
|
-
minLength: r?.minPasswordLength,
|
|
107
|
-
maxLength: r?.maxPasswordLength,
|
|
108
|
-
isDisabled: M || !C,
|
|
109
|
-
value: D,
|
|
110
|
-
onChange: O,
|
|
111
|
-
children: [
|
|
112
|
-
/* @__PURE__ */ v(f, { children: i.auth.newPassword }),
|
|
113
|
-
/* @__PURE__ */ y(d, {
|
|
114
|
-
className: g(!C && "hidden"),
|
|
115
|
-
variant: n === "transparent" ? "primary" : "secondary",
|
|
116
|
-
children: [/* @__PURE__ */ v(d.Input, {
|
|
117
|
-
name: "newPassword",
|
|
118
|
-
type: N ? "text" : "password",
|
|
119
|
-
autoComplete: "new-password",
|
|
120
|
-
placeholder: i.auth.newPasswordPlaceholder,
|
|
121
|
-
required: !0
|
|
122
|
-
}), /* @__PURE__ */ v(d.Suffix, {
|
|
123
|
-
className: "px-0",
|
|
124
|
-
children: /* @__PURE__ */ v(a, {
|
|
125
|
-
isIconOnly: !0,
|
|
126
|
-
"aria-label": N ? i.auth.hidePassword : i.auth.showPassword,
|
|
127
|
-
size: "sm",
|
|
128
|
-
variant: "ghost",
|
|
129
|
-
onPress: () => P(!N),
|
|
130
|
-
isDisabled: M,
|
|
131
|
-
children: v(N ? S : x, {})
|
|
132
|
-
})
|
|
133
|
-
})]
|
|
134
|
-
}),
|
|
135
|
-
!C && /* @__PURE__ */ v(p, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
136
|
-
/* @__PURE__ */ v(s, {})
|
|
137
|
-
]
|
|
138
|
-
}),
|
|
139
|
-
r?.confirmPassword && /* @__PURE__ */ y(h, {
|
|
140
|
-
minLength: r?.minPasswordLength,
|
|
141
|
-
maxLength: r?.maxPasswordLength,
|
|
142
|
-
isDisabled: M || !C,
|
|
143
|
-
isRequired: !0,
|
|
144
|
-
value: k,
|
|
145
|
-
onChange: A,
|
|
146
|
-
children: [
|
|
147
|
-
/* @__PURE__ */ v(f, { children: i.auth.confirmPassword }),
|
|
148
|
-
/* @__PURE__ */ y(d, {
|
|
149
|
-
className: g(!C && "hidden"),
|
|
150
|
-
variant: n === "transparent" ? "primary" : "secondary",
|
|
151
|
-
children: [/* @__PURE__ */ v(d.Input, {
|
|
152
|
-
name: "confirmPassword",
|
|
153
|
-
type: F ? "text" : "password",
|
|
154
|
-
autoComplete: "new-password",
|
|
155
|
-
placeholder: i.auth.confirmPasswordPlaceholder,
|
|
156
|
-
required: !0
|
|
157
|
-
}), /* @__PURE__ */ v(d.Suffix, {
|
|
158
|
-
className: "px-0",
|
|
159
|
-
children: /* @__PURE__ */ v(a, {
|
|
160
|
-
isIconOnly: !0,
|
|
161
|
-
"aria-label": F ? i.auth.hidePassword : i.auth.showPassword,
|
|
162
|
-
size: "sm",
|
|
163
|
-
variant: "ghost",
|
|
164
|
-
onPress: () => I(!F),
|
|
165
|
-
isDisabled: M,
|
|
166
|
-
children: v(F ? S : x, {})
|
|
167
|
-
})
|
|
168
|
-
})]
|
|
169
|
-
}),
|
|
170
|
-
!C && /* @__PURE__ */ v(p, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
171
|
-
/* @__PURE__ */ v(s, {})
|
|
172
|
-
]
|
|
173
|
-
})
|
|
174
|
-
] }), /* @__PURE__ */ v(c.Actions, { children: /* @__PURE__ */ y(a, {
|
|
175
|
-
type: "submit",
|
|
176
|
-
isPending: M,
|
|
177
|
-
isDisabled: !C,
|
|
178
|
-
size: "sm",
|
|
179
|
-
children: [M && /* @__PURE__ */ v(m, {
|
|
180
|
-
color: "current",
|
|
181
|
-
size: "sm"
|
|
182
|
-
}), i.settings.updatePassword]
|
|
183
|
-
}) })]
|
|
184
|
-
})
|
|
185
|
-
}) })
|
|
186
|
-
})] });
|
|
187
|
-
}
|
|
188
|
-
//#endregion
|
|
189
|
-
export { C as ChangePassword };
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { useAuth as e, useDeleteUser as t, useListAccounts as n } from "@better-auth-ui/react";
|
|
2
|
-
import { AlertDialog as r, Button as i, Card as a, FieldError as o, Form as s, Input as c, Label as l, Spinner as u, TextField as d, cn as f, toast as p } from "@heroui/react";
|
|
3
|
-
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
4
|
-
import { useState as g } from "react";
|
|
5
|
-
import { TriangleExclamation as _ } from "@gravity-ui/icons";
|
|
6
|
-
//#region src/components/settings/security/delete-user.tsx
|
|
7
|
-
function v({ className: v, variant: y, ...b }) {
|
|
8
|
-
let { basePaths: x, deleteUser: S, localization: C, navigate: w, viewPaths: T } = e(), { data: E } = n(), [D, O] = g(!1), [k, A] = g(""), j = E?.some((e) => e.providerId === "credential"), M = !S?.sendDeleteAccountVerification && j, { mutate: N, isPending: P } = t(), F = (e) => {
|
|
9
|
-
O(e), A("");
|
|
10
|
-
}, I = async (e) => {
|
|
11
|
-
e.preventDefault(), N({ ...M ? { password: k } : {} }, { onSuccess: () => {
|
|
12
|
-
O(!1), A(""), S?.sendDeleteAccountVerification ? p.success(C.settings.deleteUserVerificationSent) : (p.success(C.settings.deleteUserSuccess), w({
|
|
13
|
-
to: `${x.auth}/${T.auth.signIn}`,
|
|
14
|
-
replace: !0
|
|
15
|
-
}));
|
|
16
|
-
} });
|
|
17
|
-
};
|
|
18
|
-
return /* @__PURE__ */ m(a, {
|
|
19
|
-
className: f("border border-danger", v),
|
|
20
|
-
variant: y,
|
|
21
|
-
...b,
|
|
22
|
-
children: /* @__PURE__ */ h(a.Content, {
|
|
23
|
-
className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
24
|
-
children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
|
|
25
|
-
className: "text-sm font-medium leading-tight",
|
|
26
|
-
children: C.settings.deleteUser
|
|
27
|
-
}), /* @__PURE__ */ m("p", {
|
|
28
|
-
className: "text-muted text-xs mt-0.5",
|
|
29
|
-
children: C.settings.deleteUserDescription
|
|
30
|
-
})] }), /* @__PURE__ */ h(r, { children: [/* @__PURE__ */ m(i, {
|
|
31
|
-
isDisabled: !E,
|
|
32
|
-
size: "sm",
|
|
33
|
-
variant: "danger",
|
|
34
|
-
onPress: () => O(!0),
|
|
35
|
-
children: C.settings.deleteUser
|
|
36
|
-
}), /* @__PURE__ */ m(r.Backdrop, {
|
|
37
|
-
isOpen: D,
|
|
38
|
-
onOpenChange: F,
|
|
39
|
-
children: /* @__PURE__ */ m(r.Container, { children: /* @__PURE__ */ m(r.Dialog, { children: /* @__PURE__ */ h(s, {
|
|
40
|
-
onSubmit: I,
|
|
41
|
-
children: [
|
|
42
|
-
/* @__PURE__ */ m(r.CloseTrigger, {}),
|
|
43
|
-
/* @__PURE__ */ h(r.Header, { children: [/* @__PURE__ */ m(r.Icon, {
|
|
44
|
-
status: "danger",
|
|
45
|
-
children: /* @__PURE__ */ m(_, {})
|
|
46
|
-
}), /* @__PURE__ */ m(r.Heading, { children: C.settings.deleteUser })] }),
|
|
47
|
-
/* @__PURE__ */ h(r.Body, {
|
|
48
|
-
className: "overflow-visible",
|
|
49
|
-
children: [/* @__PURE__ */ m("p", {
|
|
50
|
-
className: "text-muted text-sm",
|
|
51
|
-
children: C.settings.deleteUserDescription
|
|
52
|
-
}), M && /* @__PURE__ */ h(d, {
|
|
53
|
-
className: "mt-4",
|
|
54
|
-
name: "password",
|
|
55
|
-
type: "password",
|
|
56
|
-
isDisabled: P,
|
|
57
|
-
value: k,
|
|
58
|
-
onChange: A,
|
|
59
|
-
children: [
|
|
60
|
-
/* @__PURE__ */ m(l, { children: C.auth.password }),
|
|
61
|
-
/* @__PURE__ */ m(c, {
|
|
62
|
-
autoComplete: "current-password",
|
|
63
|
-
placeholder: C.auth.passwordPlaceholder,
|
|
64
|
-
required: !0,
|
|
65
|
-
variant: "secondary"
|
|
66
|
-
}),
|
|
67
|
-
/* @__PURE__ */ m(o, {})
|
|
68
|
-
]
|
|
69
|
-
})]
|
|
70
|
-
}),
|
|
71
|
-
/* @__PURE__ */ h(r.Footer, { children: [/* @__PURE__ */ m(i, {
|
|
72
|
-
slot: "close",
|
|
73
|
-
variant: "tertiary",
|
|
74
|
-
isDisabled: P,
|
|
75
|
-
children: C.settings.cancel
|
|
76
|
-
}), /* @__PURE__ */ h(i, {
|
|
77
|
-
type: "submit",
|
|
78
|
-
variant: "danger",
|
|
79
|
-
isPending: P,
|
|
80
|
-
children: [P && /* @__PURE__ */ m(u, {
|
|
81
|
-
color: "current",
|
|
82
|
-
size: "sm"
|
|
83
|
-
}), C.settings.deleteUser]
|
|
84
|
-
})] })
|
|
85
|
-
]
|
|
86
|
-
}) }) })
|
|
87
|
-
})] })]
|
|
88
|
-
})
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
export { v as DeleteUser };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { providerIcons as e, useAccountInfo as t, useAuth as n, useLinkSocial as r, useUnlinkAccount as i } from "@better-auth-ui/react";
|
|
2
|
-
import { Button as a, Skeleton as o, Spinner as s, cn as c, toast as l } from "@heroui/react";
|
|
3
|
-
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
4
|
-
import { Link as f, LinkSlash as p, PlugConnection as m } from "@gravity-ui/icons";
|
|
5
|
-
import { getProviderName as h } from "@better-auth-ui/core";
|
|
6
|
-
//#region src/components/settings/security/linked-account.tsx
|
|
7
|
-
function g({ account: g, provider: _ }) {
|
|
8
|
-
let { baseURL: v, localization: y } = n(), { data: b, isPending: x } = t({ query: { accountId: g?.accountId } }), { mutate: S, isPending: C } = r(), { mutate: w, isPending: T } = i({ onSuccess: () => l.success(y.settings.accountUnlinked) }), E = e[_], D = h(_), O = b?.data?.login || b?.data?.username || b?.user?.email || b?.user?.name || g?.accountId;
|
|
9
|
-
return /* @__PURE__ */ d("div", {
|
|
10
|
-
className: "flex items-center gap-3",
|
|
11
|
-
children: [
|
|
12
|
-
/* @__PURE__ */ u("div", {
|
|
13
|
-
className: c("flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary"),
|
|
14
|
-
children: u(E || m, { className: c("size-4.5", !g && "opacity-50") })
|
|
15
|
-
}),
|
|
16
|
-
/* @__PURE__ */ d("div", {
|
|
17
|
-
className: "flex flex-col min-w-0",
|
|
18
|
-
children: [/* @__PURE__ */ u("span", {
|
|
19
|
-
className: "text-sm font-medium leading-tight",
|
|
20
|
-
children: D
|
|
21
|
-
}), g && x ? /* @__PURE__ */ u(o, { className: "h-3 w-24 my-0.5 rounded-lg" }) : /* @__PURE__ */ u("span", {
|
|
22
|
-
className: "text-xs text-muted truncate",
|
|
23
|
-
children: g ? O : y.settings.linkProvider.replace("{{provider}}", D)
|
|
24
|
-
})]
|
|
25
|
-
}),
|
|
26
|
-
g ? /* @__PURE__ */ d(a, {
|
|
27
|
-
className: "ml-auto shrink-0",
|
|
28
|
-
variant: "outline",
|
|
29
|
-
size: "sm",
|
|
30
|
-
onPress: () => w({ providerId: g.providerId }),
|
|
31
|
-
isPending: T,
|
|
32
|
-
"aria-label": y.settings.unlinkProvider.replace("{{provider}}", D),
|
|
33
|
-
children: [T ? /* @__PURE__ */ u(s, {
|
|
34
|
-
color: "current",
|
|
35
|
-
size: "sm"
|
|
36
|
-
}) : /* @__PURE__ */ u(p, {}), y.settings.unlinkProvider.replace("{{provider}}", "").trim()]
|
|
37
|
-
}) : /* @__PURE__ */ d(a, {
|
|
38
|
-
className: "ml-auto shrink-0",
|
|
39
|
-
variant: "outline",
|
|
40
|
-
size: "sm",
|
|
41
|
-
onPress: () => S({
|
|
42
|
-
provider: _,
|
|
43
|
-
callbackURL: `${v}${window.location.pathname}`
|
|
44
|
-
}),
|
|
45
|
-
isPending: C,
|
|
46
|
-
"aria-label": y.settings.linkProvider.replace("{{provider}}", D),
|
|
47
|
-
children: [C ? /* @__PURE__ */ u(s, {
|
|
48
|
-
color: "current",
|
|
49
|
-
size: "sm"
|
|
50
|
-
}) : /* @__PURE__ */ u(f, {}), y.settings.link]
|
|
51
|
-
})
|
|
52
|
-
]
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { g as LinkedAccount };
|