@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,50 +1,50 @@
|
|
|
1
1
|
import { useAuth as e, useChangeEmail as t, useSession as n } from "@better-auth-ui/react";
|
|
2
2
|
import { Button as r, Card as i, FieldError as a, Fieldset as o, Form as s, Input as c, Label as l, Skeleton as u, Spinner as d, TextField as f, cn as p, toast as m } from "@heroui/react";
|
|
3
3
|
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
4
|
-
//#region src/components/settings/account/change-email.tsx
|
|
4
|
+
//#region src/components/auth/settings/account/change-email.tsx
|
|
5
5
|
function _({ className: _, variant: v, ...y }) {
|
|
6
|
-
let {
|
|
7
|
-
function
|
|
8
|
-
e.preventDefault(),
|
|
6
|
+
let { authClient: b, localization: x, baseURL: S, viewPaths: C } = e(), { data: w } = n(b), { mutate: T, isPending: E } = t(b, { onSuccess: () => m.success(x.settings.changeEmailSuccess) });
|
|
7
|
+
function D(e) {
|
|
8
|
+
e.preventDefault(), T({
|
|
9
9
|
newEmail: new FormData(e.currentTarget).get("email"),
|
|
10
|
-
callbackURL: `${
|
|
10
|
+
callbackURL: `${S}/${C.settings.account}`
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
return /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("h2", {
|
|
14
14
|
className: p("text-sm font-semibold mb-3"),
|
|
15
|
-
children:
|
|
15
|
+
children: x.settings.changeEmail
|
|
16
16
|
}), /* @__PURE__ */ h(i, {
|
|
17
17
|
className: p("p-4 gap-4", _),
|
|
18
18
|
variant: v,
|
|
19
19
|
...y,
|
|
20
20
|
children: /* @__PURE__ */ h(i.Content, { children: /* @__PURE__ */ h(s, {
|
|
21
|
-
onSubmit:
|
|
21
|
+
onSubmit: D,
|
|
22
22
|
children: /* @__PURE__ */ g(o, {
|
|
23
23
|
className: "w-full gap-4",
|
|
24
24
|
children: [/* @__PURE__ */ h(o.Group, { children: /* @__PURE__ */ g(f, {
|
|
25
25
|
name: "email",
|
|
26
26
|
type: "email",
|
|
27
|
-
defaultValue:
|
|
28
|
-
isDisabled:
|
|
27
|
+
defaultValue: w?.user.email,
|
|
28
|
+
isDisabled: E || !w,
|
|
29
29
|
children: [
|
|
30
|
-
/* @__PURE__ */ h(l, { children:
|
|
31
|
-
|
|
30
|
+
/* @__PURE__ */ h(l, { children: x.auth.email }),
|
|
31
|
+
w ? /* @__PURE__ */ h(c, {
|
|
32
32
|
required: !0,
|
|
33
33
|
variant: v === "transparent" ? "primary" : "secondary",
|
|
34
34
|
autoComplete: "email",
|
|
35
|
-
placeholder:
|
|
35
|
+
placeholder: x.auth.emailPlaceholder
|
|
36
36
|
}) : /* @__PURE__ */ h(u, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
37
37
|
/* @__PURE__ */ h(a, {})
|
|
38
38
|
]
|
|
39
|
-
},
|
|
39
|
+
}, w?.user.email) }), /* @__PURE__ */ h(o.Actions, { children: /* @__PURE__ */ g(r, {
|
|
40
40
|
type: "submit",
|
|
41
|
-
isPending:
|
|
42
|
-
isDisabled: !
|
|
41
|
+
isPending: E,
|
|
42
|
+
isDisabled: !w,
|
|
43
43
|
size: "sm",
|
|
44
|
-
children: [
|
|
44
|
+
children: [E && /* @__PURE__ */ h(d, {
|
|
45
45
|
color: "current",
|
|
46
46
|
size: "sm"
|
|
47
|
-
}),
|
|
47
|
+
}), x.settings.updateEmail]
|
|
48
48
|
}) })]
|
|
49
49
|
})
|
|
50
50
|
}) })
|
|
@@ -4,8 +4,7 @@ export type UserProfileProps = {
|
|
|
4
4
|
variant?: CardProps["variant"];
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
|
-
* Render a profile card that lets the authenticated user view and update their
|
|
8
|
-
*
|
|
9
|
-
* @returns A JSX element containing the user profile card with avatar upload and editable form fields
|
|
7
|
+
* Render a profile card that lets the authenticated user view and update their
|
|
8
|
+
* display name, avatar, and any plugin- or user-supplied additional fields.
|
|
10
9
|
*/
|
|
11
10
|
export declare function UserProfile({ className, variant, ...props }: UserProfileProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { AdditionalField as e } from "../../additional-field.js";
|
|
2
|
+
import { ChangeAvatar as t } from "./change-avatar.js";
|
|
3
|
+
import { parseAdditionalFieldValue as n } from "@better-auth-ui/core";
|
|
4
|
+
import { useAuth as r, useSession as i, useUpdateUser as a } from "@better-auth-ui/react";
|
|
5
|
+
import { Button as o, Card as s, FieldError as c, Form as l, Input as u, Label as d, Skeleton as f, Spinner as p, TextField as m, cn as h, toast as g } from "@heroui/react";
|
|
6
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/auth/settings/account/user-profile.tsx
|
|
8
|
+
function y({ className: y, variant: b, ...x }) {
|
|
9
|
+
let { additionalFields: S, authClient: C, localization: w } = r(), { data: T } = i(C), { mutate: E, isPending: D } = a(C, { onSuccess: () => g.success(w.settings.profileUpdatedSuccess) });
|
|
10
|
+
async function O(e) {
|
|
11
|
+
e.preventDefault();
|
|
12
|
+
let t = new FormData(e.currentTarget), r = t.get("name"), i = {};
|
|
13
|
+
for (let e of S ?? []) {
|
|
14
|
+
if (e.profile === !1 || e.readOnly) continue;
|
|
15
|
+
let r = n(e, t.get(e.name));
|
|
16
|
+
if (e.validate) try {
|
|
17
|
+
await e.validate(r);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
g.danger(e instanceof Error ? e.message : String(e));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
r !== void 0 && (i[e.name] = r);
|
|
23
|
+
}
|
|
24
|
+
E({
|
|
25
|
+
name: r,
|
|
26
|
+
...i
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("h2", {
|
|
30
|
+
className: h("text-sm font-semibold mb-3"),
|
|
31
|
+
children: w.settings.profile
|
|
32
|
+
}), /* @__PURE__ */ _(s, {
|
|
33
|
+
className: h("p-4 gap-4", y),
|
|
34
|
+
variant: b,
|
|
35
|
+
...x,
|
|
36
|
+
children: /* @__PURE__ */ _(s.Content, { children: /* @__PURE__ */ v(l, {
|
|
37
|
+
onSubmit: O,
|
|
38
|
+
className: "flex flex-col gap-4",
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ _(t, {}),
|
|
41
|
+
/* @__PURE__ */ v(m, {
|
|
42
|
+
name: "name",
|
|
43
|
+
defaultValue: T?.user.name,
|
|
44
|
+
isDisabled: D || !T,
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ _(d, { children: w.auth.name }),
|
|
47
|
+
/* @__PURE__ */ _(u, {
|
|
48
|
+
className: h(!T && "hidden"),
|
|
49
|
+
autoComplete: "name",
|
|
50
|
+
placeholder: w.auth.name,
|
|
51
|
+
variant: b === "transparent" ? "primary" : "secondary"
|
|
52
|
+
}),
|
|
53
|
+
!T && /* @__PURE__ */ _(f, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
54
|
+
/* @__PURE__ */ _(c, {})
|
|
55
|
+
]
|
|
56
|
+
}, T?.user?.name),
|
|
57
|
+
S?.filter((e) => e.profile !== !1).map((t) => {
|
|
58
|
+
if (!T) return t.inputType === "hidden" ? null : /* @__PURE__ */ _(f, { className: "h-10 md:h-9 w-full rounded-xl" }, t.name);
|
|
59
|
+
let n = T.user[t.name], r = `${t.name}:${n instanceof Date ? n.toISOString() : String(n ?? "")}`;
|
|
60
|
+
return /* @__PURE__ */ _(e, {
|
|
61
|
+
name: t.name,
|
|
62
|
+
field: {
|
|
63
|
+
...t,
|
|
64
|
+
defaultValue: n
|
|
65
|
+
},
|
|
66
|
+
isPending: D,
|
|
67
|
+
variant: b
|
|
68
|
+
}, r);
|
|
69
|
+
}),
|
|
70
|
+
/* @__PURE__ */ v(o, {
|
|
71
|
+
type: "submit",
|
|
72
|
+
isPending: D,
|
|
73
|
+
isDisabled: !T,
|
|
74
|
+
size: "sm",
|
|
75
|
+
className: "self-start mt-1",
|
|
76
|
+
children: [D && /* @__PURE__ */ _(p, {
|
|
77
|
+
color: "current",
|
|
78
|
+
size: "sm"
|
|
79
|
+
}), w.settings.saveChanges]
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
}) })
|
|
83
|
+
})] });
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { y as UserProfile };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useAuth as e, useRevokeSession as t, useSession as n } from "@better-auth-ui/react";
|
|
2
|
+
import { ArrowRightFromSquare as r, Display as i, Smartphone as a, Xmark as o } from "@gravity-ui/icons";
|
|
3
|
+
import { Button as s, Chip as c, Spinner as l, toast as u } from "@heroui/react";
|
|
4
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
5
|
+
import p from "bowser";
|
|
6
|
+
//#region src/components/auth/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 { authClient: g, basePaths: _, localization: v, viewPaths: y, navigate: b } = e(), { data: x } = n(g, { refetchOnMount: !1 }), { mutate: S, isPending: C } = t(g, { onSuccess: () => u.success(v.settings.revokeSessionSuccess) }), w = h.token === x?.session.token, T = p.parse(h.userAgent || "");
|
|
22
|
+
return /* @__PURE__ */ f("div", {
|
|
23
|
+
className: "flex items-center gap-3",
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ d("div", {
|
|
26
|
+
className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary",
|
|
27
|
+
children: T.platform.type === "mobile" || T.platform.type === "tablet" ? /* @__PURE__ */ d(a, { className: "size-4.5" }) : /* @__PURE__ */ d(i, { className: "size-4.5" })
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ f("div", {
|
|
30
|
+
className: "flex flex-col min-w-0",
|
|
31
|
+
children: [/* @__PURE__ */ f("span", {
|
|
32
|
+
className: "text-sm font-medium truncate",
|
|
33
|
+
children: [T.browser.name || "Unknown Browser", T.os.name ? `, ${T.os.name}` : ""]
|
|
34
|
+
}), w ? /* @__PURE__ */ d(c, {
|
|
35
|
+
color: "accent",
|
|
36
|
+
size: "sm",
|
|
37
|
+
children: v.settings.currentSession
|
|
38
|
+
}) : h.createdAt && /* @__PURE__ */ d("span", {
|
|
39
|
+
className: "text-xs text-muted capitalize",
|
|
40
|
+
children: m(h.createdAt)
|
|
41
|
+
})]
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ f(s, {
|
|
44
|
+
className: "ml-auto shrink-0",
|
|
45
|
+
variant: "outline",
|
|
46
|
+
size: "sm",
|
|
47
|
+
onPress: () => w ? b({ to: `${_.auth}/${y.auth.signOut}` }) : S(h),
|
|
48
|
+
isPending: C,
|
|
49
|
+
"aria-label": w ? v.auth.signOut : v.settings.revokeSession,
|
|
50
|
+
children: [C ? /* @__PURE__ */ d(l, {
|
|
51
|
+
color: "current",
|
|
52
|
+
size: "sm"
|
|
53
|
+
}) : d(w ? r : o, {}), w ? v.auth.signOut : v.settings.revoke]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { h as ActiveSession };
|
|
@@ -2,19 +2,19 @@ import { ActiveSession as e } from "./active-session.js";
|
|
|
2
2
|
import { useAuth as t, useListSessions as n, useSession as r } from "@better-auth-ui/react";
|
|
3
3
|
import { Card as i, Skeleton as a, cn as o } from "@heroui/react";
|
|
4
4
|
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
5
|
-
//#region src/components/settings/security/active-sessions.tsx
|
|
5
|
+
//#region src/components/auth/settings/security/active-sessions.tsx
|
|
6
6
|
function l({ className: a, variant: l, ...d }) {
|
|
7
|
-
let {
|
|
7
|
+
let { authClient: f, localization: p } = t(), { data: m } = r(f), { data: h, isPending: g } = n(f), _ = h?.toSorted((e) => e.id === m?.session.id ? -1 : 1);
|
|
8
8
|
return /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("h2", {
|
|
9
9
|
className: o("text-sm font-semibold mb-3"),
|
|
10
|
-
children:
|
|
10
|
+
children: p.settings.activeSessions
|
|
11
11
|
}), /* @__PURE__ */ s(i, {
|
|
12
12
|
className: o(a),
|
|
13
13
|
variant: l,
|
|
14
14
|
...d,
|
|
15
15
|
children: /* @__PURE__ */ s(i.Content, {
|
|
16
16
|
className: "gap-0",
|
|
17
|
-
children:
|
|
17
|
+
children: g ? /* @__PURE__ */ s(u, {}) : _?.map((t, n) => /* @__PURE__ */ c("div", { children: [n > 0 && /* @__PURE__ */ s("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ s(e, { activeSession: t })] }, t.id))
|
|
18
18
|
})
|
|
19
19
|
})] });
|
|
20
20
|
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { useAuth as e, useChangePassword as t, useListAccounts as n, useRequestPasswordReset as r, useSession as i } from "@better-auth-ui/react";
|
|
2
|
+
import { Eye as a, EyeSlash as o } from "@gravity-ui/icons";
|
|
3
|
+
import { Button as s, Card as c, FieldError as l, Fieldset as u, Form as d, Input as f, InputGroup as p, Label as m, Skeleton as h, Spinner as g, TextField as _, cn as v, toast as y } from "@heroui/react";
|
|
4
|
+
import { useState as b } from "react";
|
|
5
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/auth/settings/security/change-password.tsx
|
|
7
|
+
function C({ className: t, variant: r, ...a }) {
|
|
8
|
+
let { authClient: o, emailAndPassword: s, localization: c } = e(), { data: l } = i(o), { data: u, isPending: d } = n(o), f = u?.some((e) => e.providerId === "credential");
|
|
9
|
+
return !d && !f ? /* @__PURE__ */ x(w, {
|
|
10
|
+
className: t,
|
|
11
|
+
variant: r,
|
|
12
|
+
...a
|
|
13
|
+
}) : /* @__PURE__ */ x(T, {
|
|
14
|
+
className: t,
|
|
15
|
+
variant: r,
|
|
16
|
+
emailAndPassword: s,
|
|
17
|
+
localization: c,
|
|
18
|
+
session: d ? void 0 : l,
|
|
19
|
+
...a
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function w({ className: t, variant: n, ...a }) {
|
|
23
|
+
let { authClient: o, localization: l } = e(), { data: u } = i(o), { mutate: d, isPending: f } = r(o, { onSuccess: () => y.success(l.auth.passwordResetEmailSent) }), p = () => {
|
|
24
|
+
u?.user.email && d({ email: u.user.email });
|
|
25
|
+
};
|
|
26
|
+
return /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("h2", {
|
|
27
|
+
className: v("text-sm font-semibold mb-3"),
|
|
28
|
+
children: l.settings.changePassword
|
|
29
|
+
}), /* @__PURE__ */ x(c, {
|
|
30
|
+
className: v(t),
|
|
31
|
+
variant: n,
|
|
32
|
+
...a,
|
|
33
|
+
children: /* @__PURE__ */ S(c.Content, {
|
|
34
|
+
className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
35
|
+
children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("p", {
|
|
36
|
+
className: "text-sm font-medium leading-tight",
|
|
37
|
+
children: l.settings.setPassword
|
|
38
|
+
}), /* @__PURE__ */ x("p", {
|
|
39
|
+
className: "text-muted text-xs mt-0.5",
|
|
40
|
+
children: l.settings.setPasswordDescription
|
|
41
|
+
})] }), /* @__PURE__ */ S(s, {
|
|
42
|
+
size: "sm",
|
|
43
|
+
isPending: f,
|
|
44
|
+
isDisabled: !u,
|
|
45
|
+
onPress: p,
|
|
46
|
+
children: [f && /* @__PURE__ */ x(g, {
|
|
47
|
+
color: "current",
|
|
48
|
+
size: "sm"
|
|
49
|
+
}), l.auth.sendResetLink]
|
|
50
|
+
})]
|
|
51
|
+
})
|
|
52
|
+
})] });
|
|
53
|
+
}
|
|
54
|
+
function T({ className: n, variant: r, emailAndPassword: i, localization: C, session: w, ...T }) {
|
|
55
|
+
let { authClient: E } = e(), [D, O] = b(""), [k, A] = b(""), [j, M] = b(""), { mutate: N, isPending: P } = t(E, {
|
|
56
|
+
onError: (e) => {
|
|
57
|
+
O(""), A(""), M(""), y.danger(e.error?.message || e.message);
|
|
58
|
+
},
|
|
59
|
+
onSuccess: () => {
|
|
60
|
+
O(""), A(""), M(""), y.success(C.settings.changePasswordSuccess);
|
|
61
|
+
}
|
|
62
|
+
}), [F, I] = b(!1), [L, R] = b(!1), z = (e) => {
|
|
63
|
+
if (e.preventDefault(), i?.confirmPassword && k !== j) {
|
|
64
|
+
O(""), A(""), M(""), y.danger(C.auth.passwordsDoNotMatch);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
N({
|
|
68
|
+
currentPassword: D,
|
|
69
|
+
newPassword: k,
|
|
70
|
+
revokeOtherSessions: !0
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
return /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("h2", {
|
|
74
|
+
className: v("text-sm font-semibold mb-3"),
|
|
75
|
+
children: C.settings.changePassword
|
|
76
|
+
}), /* @__PURE__ */ x(c, {
|
|
77
|
+
className: v("p-4 gap-4", n),
|
|
78
|
+
variant: r,
|
|
79
|
+
...T,
|
|
80
|
+
children: /* @__PURE__ */ x(c.Content, { children: /* @__PURE__ */ x(d, {
|
|
81
|
+
onSubmit: z,
|
|
82
|
+
children: /* @__PURE__ */ S(u, {
|
|
83
|
+
className: "w-full gap-4",
|
|
84
|
+
children: [/* @__PURE__ */ S(u.Group, { children: [
|
|
85
|
+
/* @__PURE__ */ S(_, {
|
|
86
|
+
name: "currentPassword",
|
|
87
|
+
type: "password",
|
|
88
|
+
isDisabled: P || !w,
|
|
89
|
+
defaultValue: "",
|
|
90
|
+
value: D,
|
|
91
|
+
onChange: O,
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ x(m, { children: C.settings.currentPassword }),
|
|
94
|
+
/* @__PURE__ */ x(f, {
|
|
95
|
+
className: v(!w && "hidden"),
|
|
96
|
+
autoComplete: "current-password",
|
|
97
|
+
placeholder: C.settings.currentPasswordPlaceholder,
|
|
98
|
+
required: !0,
|
|
99
|
+
variant: r === "transparent" ? "primary" : "secondary"
|
|
100
|
+
}),
|
|
101
|
+
!w && /* @__PURE__ */ x(h, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
102
|
+
/* @__PURE__ */ x(l, {})
|
|
103
|
+
]
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ S(_, {
|
|
106
|
+
minLength: i?.minPasswordLength,
|
|
107
|
+
maxLength: i?.maxPasswordLength,
|
|
108
|
+
isDisabled: P || !w,
|
|
109
|
+
value: k,
|
|
110
|
+
onChange: A,
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ x(m, { children: C.auth.newPassword }),
|
|
113
|
+
/* @__PURE__ */ S(p, {
|
|
114
|
+
className: v(!w && "hidden"),
|
|
115
|
+
variant: r === "transparent" ? "primary" : "secondary",
|
|
116
|
+
children: [/* @__PURE__ */ x(p.Input, {
|
|
117
|
+
name: "newPassword",
|
|
118
|
+
type: F ? "text" : "password",
|
|
119
|
+
autoComplete: "new-password",
|
|
120
|
+
placeholder: C.auth.newPasswordPlaceholder,
|
|
121
|
+
required: !0
|
|
122
|
+
}), /* @__PURE__ */ x(p.Suffix, {
|
|
123
|
+
className: "px-0",
|
|
124
|
+
children: /* @__PURE__ */ x(s, {
|
|
125
|
+
isIconOnly: !0,
|
|
126
|
+
"aria-label": F ? C.auth.hidePassword : C.auth.showPassword,
|
|
127
|
+
size: "sm",
|
|
128
|
+
variant: "ghost",
|
|
129
|
+
onPress: () => I(!F),
|
|
130
|
+
isDisabled: P,
|
|
131
|
+
children: x(F ? o : a, {})
|
|
132
|
+
})
|
|
133
|
+
})]
|
|
134
|
+
}),
|
|
135
|
+
!w && /* @__PURE__ */ x(h, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
136
|
+
/* @__PURE__ */ x(l, {})
|
|
137
|
+
]
|
|
138
|
+
}),
|
|
139
|
+
i?.confirmPassword && /* @__PURE__ */ S(_, {
|
|
140
|
+
minLength: i?.minPasswordLength,
|
|
141
|
+
maxLength: i?.maxPasswordLength,
|
|
142
|
+
isDisabled: P || !w,
|
|
143
|
+
isRequired: !0,
|
|
144
|
+
value: j,
|
|
145
|
+
onChange: M,
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ x(m, { children: C.auth.confirmPassword }),
|
|
148
|
+
/* @__PURE__ */ S(p, {
|
|
149
|
+
className: v(!w && "hidden"),
|
|
150
|
+
variant: r === "transparent" ? "primary" : "secondary",
|
|
151
|
+
children: [/* @__PURE__ */ x(p.Input, {
|
|
152
|
+
name: "confirmPassword",
|
|
153
|
+
type: L ? "text" : "password",
|
|
154
|
+
autoComplete: "new-password",
|
|
155
|
+
placeholder: C.auth.confirmPasswordPlaceholder,
|
|
156
|
+
required: !0
|
|
157
|
+
}), /* @__PURE__ */ x(p.Suffix, {
|
|
158
|
+
className: "px-0",
|
|
159
|
+
children: /* @__PURE__ */ x(s, {
|
|
160
|
+
isIconOnly: !0,
|
|
161
|
+
"aria-label": L ? C.auth.hidePassword : C.auth.showPassword,
|
|
162
|
+
size: "sm",
|
|
163
|
+
variant: "ghost",
|
|
164
|
+
onPress: () => R(!L),
|
|
165
|
+
isDisabled: P,
|
|
166
|
+
children: x(L ? o : a, {})
|
|
167
|
+
})
|
|
168
|
+
})]
|
|
169
|
+
}),
|
|
170
|
+
!w && /* @__PURE__ */ x(h, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
171
|
+
/* @__PURE__ */ x(l, {})
|
|
172
|
+
]
|
|
173
|
+
})
|
|
174
|
+
] }), /* @__PURE__ */ x(u.Actions, { children: /* @__PURE__ */ S(s, {
|
|
175
|
+
type: "submit",
|
|
176
|
+
isPending: P,
|
|
177
|
+
isDisabled: !w,
|
|
178
|
+
size: "sm",
|
|
179
|
+
children: [P && /* @__PURE__ */ x(g, {
|
|
180
|
+
color: "current",
|
|
181
|
+
size: "sm"
|
|
182
|
+
}), C.settings.updatePassword]
|
|
183
|
+
}) })]
|
|
184
|
+
})
|
|
185
|
+
}) })
|
|
186
|
+
})] });
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
export { C as ChangePassword };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { getProviderName as e } from "@better-auth-ui/core";
|
|
2
|
+
import { providerIcons as t, useAccountInfo as n, useAuth as r, useLinkSocial as i, useUnlinkAccount as a } from "@better-auth-ui/react";
|
|
3
|
+
import { Link as o, LinkSlash as s, PlugConnection as c } from "@gravity-ui/icons";
|
|
4
|
+
import { Button as l, Skeleton as u, Spinner as d, cn as f, toast as p } from "@heroui/react";
|
|
5
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/auth/settings/security/linked-account.tsx
|
|
7
|
+
function g({ account: g, provider: _ }) {
|
|
8
|
+
let { authClient: v, baseURL: y, localization: b } = r(), { data: x, isPending: S } = n(v, { query: { accountId: g?.accountId } }), { mutate: C, isPending: w } = i(v), { mutate: T, isPending: E } = a(v, { onSuccess: () => p.success(b.settings.accountUnlinked) }), D = t[_], O = e(_), k = x?.data?.login || x?.data?.username || x?.user?.email || x?.user?.name || g?.accountId;
|
|
9
|
+
return /* @__PURE__ */ h("div", {
|
|
10
|
+
className: "flex items-center gap-3",
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ m("div", {
|
|
13
|
+
className: f("flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary"),
|
|
14
|
+
children: m(D || c, { className: f("size-4.5", !g && "opacity-50") })
|
|
15
|
+
}),
|
|
16
|
+
/* @__PURE__ */ h("div", {
|
|
17
|
+
className: "flex flex-col min-w-0",
|
|
18
|
+
children: [/* @__PURE__ */ m("span", {
|
|
19
|
+
className: "text-sm font-medium leading-tight",
|
|
20
|
+
children: O
|
|
21
|
+
}), g && S ? /* @__PURE__ */ m(u, { className: "h-3 w-24 my-0.5 rounded-lg" }) : /* @__PURE__ */ m("span", {
|
|
22
|
+
className: "text-xs text-muted truncate",
|
|
23
|
+
children: g ? k : b.settings.linkProvider.replace("{{provider}}", O)
|
|
24
|
+
})]
|
|
25
|
+
}),
|
|
26
|
+
g ? /* @__PURE__ */ h(l, {
|
|
27
|
+
className: "ml-auto shrink-0",
|
|
28
|
+
variant: "outline",
|
|
29
|
+
size: "sm",
|
|
30
|
+
onPress: () => T({ providerId: g.providerId }),
|
|
31
|
+
isPending: E,
|
|
32
|
+
"aria-label": b.settings.unlinkProvider.replace("{{provider}}", O),
|
|
33
|
+
children: [E ? /* @__PURE__ */ m(d, {
|
|
34
|
+
color: "current",
|
|
35
|
+
size: "sm"
|
|
36
|
+
}) : /* @__PURE__ */ m(s, {}), b.settings.unlinkProvider.replace("{{provider}}", "").trim()]
|
|
37
|
+
}) : /* @__PURE__ */ h(l, {
|
|
38
|
+
className: "ml-auto shrink-0",
|
|
39
|
+
variant: "outline",
|
|
40
|
+
size: "sm",
|
|
41
|
+
onPress: () => C({
|
|
42
|
+
provider: _,
|
|
43
|
+
callbackURL: `${y}${window.location.pathname}`
|
|
44
|
+
}),
|
|
45
|
+
isPending: w,
|
|
46
|
+
"aria-label": b.settings.linkProvider.replace("{{provider}}", O),
|
|
47
|
+
children: [w ? /* @__PURE__ */ m(d, {
|
|
48
|
+
color: "current",
|
|
49
|
+
size: "sm"
|
|
50
|
+
}) : /* @__PURE__ */ m(o, {}), b.settings.link]
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { g as LinkedAccount };
|
|
@@ -2,27 +2,27 @@ import { LinkedAccount as e } from "./linked-account.js";
|
|
|
2
2
|
import { useAuth as t, useListAccounts as n } from "@better-auth-ui/react";
|
|
3
3
|
import { Card as r, Skeleton as i, cn as a } from "@heroui/react";
|
|
4
4
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
-
//#region src/components/settings/security/linked-accounts.tsx
|
|
5
|
+
//#region src/components/auth/settings/security/linked-accounts.tsx
|
|
6
6
|
function c({ className: i, variant: c, ...u }) {
|
|
7
|
-
let {
|
|
7
|
+
let { authClient: d, localization: f, socialProviders: p } = t(), { data: m, isPending: h } = n(d), g = [...(m?.filter((e) => e.providerId !== "credential"))?.map((e) => ({
|
|
8
8
|
key: e.id,
|
|
9
9
|
account: e,
|
|
10
10
|
provider: e.providerId
|
|
11
|
-
})) ?? [], ...
|
|
11
|
+
})) ?? [], ...p?.map((e) => ({
|
|
12
12
|
key: e,
|
|
13
13
|
account: void 0,
|
|
14
14
|
provider: e
|
|
15
15
|
})) ?? []];
|
|
16
16
|
return /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("h2", {
|
|
17
17
|
className: a("text-sm font-semibold mb-3"),
|
|
18
|
-
children:
|
|
18
|
+
children: f.settings.linkedAccounts
|
|
19
19
|
}), /* @__PURE__ */ o(r, {
|
|
20
20
|
className: a(i),
|
|
21
21
|
variant: c,
|
|
22
22
|
...u,
|
|
23
23
|
children: /* @__PURE__ */ o(r.Content, {
|
|
24
24
|
className: "gap-0",
|
|
25
|
-
children:
|
|
25
|
+
children: h ? p?.map((e, t) => /* @__PURE__ */ s("div", { children: [t > 0 && /* @__PURE__ */ o("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ o(l, {})] }, e)) : 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
26
|
account: t.account,
|
|
27
27
|
provider: t.provider
|
|
28
28
|
})] }, t.key))
|
|
@@ -8,7 +8,7 @@ export type SecuritySettingsProps = {
|
|
|
8
8
|
* Renders the security settings layout including password management, linked accounts, and active sessions.
|
|
9
9
|
*
|
|
10
10
|
* ChangePassword is rendered when password authentication is enabled; LinkedAccounts is rendered when social providers are present.
|
|
11
|
-
*
|
|
11
|
+
* Each registered auth plugin may contribute `securityCards` (for example delete-user, passkeys).
|
|
12
12
|
*
|
|
13
13
|
* @param className - Optional additional CSS class names for the outer container.
|
|
14
14
|
* @param variant - Card variant forwarded to each security settings card.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ActiveSessions as e } from "./active-sessions.js";
|
|
2
|
+
import { ChangePassword as t } from "./change-password.js";
|
|
3
|
+
import { LinkedAccounts as n } from "./linked-accounts.js";
|
|
4
|
+
import { useAuth as r } from "@better-auth-ui/react";
|
|
5
|
+
import { cn as i } from "@heroui/react";
|
|
6
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/auth/settings/security/security-settings.tsx
|
|
8
|
+
function s({ className: s, variant: c, ...l }) {
|
|
9
|
+
let { emailAndPassword: u, plugins: d, socialProviders: f } = r();
|
|
10
|
+
return /* @__PURE__ */ o("div", {
|
|
11
|
+
className: i("flex w-full flex-col gap-4 md:gap-6", s),
|
|
12
|
+
...l,
|
|
13
|
+
children: [
|
|
14
|
+
u?.enabled && /* @__PURE__ */ a(t, { variant: c }),
|
|
15
|
+
!!f?.length && /* @__PURE__ */ a(n, { variant: c }),
|
|
16
|
+
/* @__PURE__ */ a(e, { variant: c }),
|
|
17
|
+
d.flatMap((e) => e.securityCards?.map((t, n) => /* @__PURE__ */ a(t, { variant: c }, `${e.id}-${n.toString()}`)))
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { s as SecuritySettings };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AccountSettings as e } from "./account/account-settings.js";
|
|
2
|
+
import { SecuritySettings as t } from "./security/security-settings.js";
|
|
3
|
+
import { useAuth as n, useAuthenticate as r } from "@better-auth-ui/react";
|
|
4
|
+
import { Tabs as i, cn as a } from "@heroui/react";
|
|
5
|
+
import { useMemo as o } from "react";
|
|
6
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/auth/settings/settings.tsx
|
|
8
|
+
function l({ className: l, hideNav: u, path: d, variant: f, view: p, ...m }) {
|
|
9
|
+
let { authClient: h, basePaths: g, localization: _, viewPaths: v } = n();
|
|
10
|
+
if (r(h), !p && !d) throw Error("[Better Auth UI] Either `view` or `path` must be provided");
|
|
11
|
+
let y = o(() => Object.fromEntries(Object.entries(v.settings).map(([e, t]) => [t, e])), [v.settings]), b = p || (d ? y[d] : void 0);
|
|
12
|
+
return /* @__PURE__ */ c(i, {
|
|
13
|
+
className: a(l),
|
|
14
|
+
orientation: "horizontal",
|
|
15
|
+
selectedKey: b,
|
|
16
|
+
...m,
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ s(i.ListContainer, { children: /* @__PURE__ */ c(i.List, {
|
|
19
|
+
"aria-label": _.settings.settings,
|
|
20
|
+
className: "overflow-auto w-fit",
|
|
21
|
+
children: [/* @__PURE__ */ c(i.Tab, {
|
|
22
|
+
id: "account",
|
|
23
|
+
href: `${g.settings}/${v.settings.account}`,
|
|
24
|
+
children: [_.settings.account, /* @__PURE__ */ s(i.Indicator, {})]
|
|
25
|
+
}), /* @__PURE__ */ c(i.Tab, {
|
|
26
|
+
id: "security",
|
|
27
|
+
href: `${g.settings}/${v.settings.security}`,
|
|
28
|
+
children: [_.settings.security, /* @__PURE__ */ s(i.Indicator, {})]
|
|
29
|
+
})]
|
|
30
|
+
}) }),
|
|
31
|
+
/* @__PURE__ */ s(i.Panel, {
|
|
32
|
+
id: "account",
|
|
33
|
+
className: "px-0",
|
|
34
|
+
children: /* @__PURE__ */ s(e, { variant: f })
|
|
35
|
+
}),
|
|
36
|
+
/* @__PURE__ */ s(i.Panel, {
|
|
37
|
+
id: "security",
|
|
38
|
+
className: "px-0",
|
|
39
|
+
children: /* @__PURE__ */ s(t, { variant: f })
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { l as Settings };
|