@better-auth-ui/heroui 1.6.8 → 1.6.9
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 +2 -2
- package/dist/components/auth/additional-field.js +133 -266
- package/dist/components/auth/api-key/api-key-skeleton.js +4 -20
- package/dist/components/auth/api-key/api-key.d.ts +6 -2
- package/dist/components/auth/api-key/api-key.js +16 -54
- package/dist/components/auth/api-key/api-keys-empty.d.ts +3 -1
- package/dist/components/auth/api-key/api-keys-empty.js +8 -34
- package/dist/components/auth/api-key/api-keys.d.ts +10 -2
- package/dist/components/auth/api-key/api-keys.js +21 -40
- package/dist/components/auth/api-key/create-api-key-dialog.d.ts +3 -1
- package/dist/components/auth/api-key/create-api-key-dialog.js +43 -73
- package/dist/components/auth/api-key/delete-api-key-dialog.d.ts +4 -2
- package/dist/components/auth/api-key/delete-api-key-dialog.js +16 -50
- package/dist/components/auth/api-key/new-api-key-dialog.js +23 -59
- package/dist/components/auth/api-key/organization-api-keys.d.ts +14 -0
- package/dist/components/auth/api-key/organization-api-keys.js +22 -0
- package/dist/components/auth/auth-provider.d.ts +1 -1
- package/dist/components/auth/auth-provider.js +10 -16
- package/dist/components/auth/auth.d.ts +3 -3
- package/dist/components/auth/auth.js +86 -61
- package/dist/components/auth/delete-user/danger-zone.d.ts +3 -3
- package/dist/components/auth/delete-user/danger-zone.js +11 -17
- package/dist/components/auth/delete-user/delete-account.d.ts +9 -0
- package/dist/components/auth/delete-user/delete-account.js +50 -0
- package/dist/components/auth/email/email-changed-email.d.ts +2 -2
- package/dist/components/auth/email/email-changed-email.js +22 -29
- package/dist/components/auth/email/email-verification-email.d.ts +2 -2
- package/dist/components/auth/email/email-verification-email.js +22 -29
- package/dist/components/auth/email/magic-link-email.d.ts +2 -2
- package/dist/components/auth/email/magic-link-email.js +22 -29
- package/dist/components/auth/email/new-device-email.d.ts +2 -2
- package/dist/components/auth/email/new-device-email.js +22 -29
- package/dist/components/auth/email/organization-invitation-email.d.ts +3 -0
- package/dist/components/auth/email/organization-invitation-email.js +23 -0
- package/dist/components/auth/email/otp-email.d.ts +2 -2
- package/dist/components/auth/email/otp-email.js +21 -28
- package/dist/components/auth/email/password-changed-email.d.ts +2 -2
- package/dist/components/auth/email/password-changed-email.js +22 -29
- package/dist/components/auth/email/reset-password-email.d.ts +2 -2
- package/dist/components/auth/email/reset-password-email.js +22 -29
- package/dist/components/auth/error-toaster.js +32 -16
- package/dist/components/auth/field-separator.d.ts +1 -1
- package/dist/components/auth/field-separator.js +4 -17
- package/dist/components/auth/forgot-password.d.ts +1 -1
- package/dist/components/auth/forgot-password.js +36 -88
- package/dist/components/auth/magic-link/magic-link-button.d.ts +1 -1
- package/dist/components/auth/magic-link/magic-link-button.js +33 -19
- package/dist/components/auth/magic-link/magic-link.d.ts +2 -2
- package/dist/components/auth/magic-link/magic-link.js +39 -86
- package/dist/components/auth/multi-session/manage-account.d.ts +1 -1
- package/dist/components/auth/multi-session/manage-account.js +32 -48
- package/dist/components/auth/multi-session/manage-accounts.d.ts +1 -1
- package/dist/components/auth/multi-session/manage-accounts.js +32 -33
- package/dist/components/auth/multi-session/switch-account-submenu-content.d.ts +3 -1
- package/dist/components/auth/multi-session/switch-account-submenu-content.js +24 -27
- package/dist/components/auth/multi-session/switch-account-submenu-item.d.ts +3 -2
- package/dist/components/auth/multi-session/switch-account-submenu-item.js +16 -19
- package/dist/components/auth/multi-session/switch-account-submenu.d.ts +2 -1
- package/dist/components/auth/multi-session/switch-account-submenu.js +23 -23
- package/dist/components/auth/organization/change-organization-logo.d.ts +4 -0
- package/dist/components/auth/organization/change-organization-logo.js +69 -0
- package/dist/components/auth/organization/create-organization-dialog.d.ts +13 -0
- package/dist/components/auth/organization/create-organization-dialog.js +37 -0
- package/dist/components/auth/organization/delete-organization-dialog.d.ts +7 -0
- package/dist/components/auth/organization/delete-organization-dialog.js +25 -0
- package/dist/components/auth/organization/delete-organization-skeleton.d.ts +4 -0
- package/dist/components/auth/organization/delete-organization-skeleton.js +8 -0
- package/dist/components/auth/organization/delete-organization.d.ts +5 -0
- package/dist/components/auth/organization/delete-organization.js +27 -0
- package/dist/components/auth/organization/invite-member-dialog.d.ts +13 -0
- package/dist/components/auth/organization/invite-member-dialog.js +47 -0
- package/dist/components/auth/organization/leave-organization-dialog.d.ts +7 -0
- package/dist/components/auth/organization/leave-organization-dialog.js +21 -0
- package/dist/components/auth/organization/leave-organization.d.ts +4 -0
- package/dist/components/auth/organization/leave-organization.js +16 -0
- package/dist/components/auth/organization/organization-danger-zone.d.ts +16 -0
- package/dist/components/auth/organization/organization-danger-zone.js +23 -0
- package/dist/components/auth/organization/organization-invitation-row-skeleton.d.ts +5 -0
- package/dist/components/auth/organization/organization-invitation-row-skeleton.js +9 -0
- package/dist/components/auth/organization/organization-invitation-row.d.ts +5 -0
- package/dist/components/auth/organization/organization-invitation-row.js +31 -0
- package/dist/components/auth/organization/organization-invitations-empty.d.ts +8 -0
- package/dist/components/auth/organization/organization-invitations-empty.js +13 -0
- package/dist/components/auth/organization/organization-invitations.d.ts +9 -0
- package/dist/components/auth/organization/organization-invitations.js +66 -0
- package/dist/components/auth/organization/organization-logo.d.ts +15 -0
- package/dist/components/auth/organization/organization-logo.js +14 -0
- package/dist/components/auth/organization/organization-member-row-skeleton.d.ts +4 -0
- package/dist/components/auth/organization/organization-member-row-skeleton.js +9 -0
- package/dist/components/auth/organization/organization-member-row.d.ts +9 -0
- package/dist/components/auth/organization/organization-member-row.js +34 -0
- package/dist/components/auth/organization/organization-members.d.ts +9 -0
- package/dist/components/auth/organization/organization-members.js +67 -0
- package/dist/components/auth/organization/organization-people.d.ts +10 -0
- package/dist/components/auth/organization/organization-people.js +11 -0
- package/dist/components/auth/organization/organization-profile.d.ts +9 -0
- package/dist/components/auth/organization/organization-profile.js +34 -0
- package/dist/components/auth/organization/organization-row.d.ts +8 -0
- package/dist/components/auth/organization/organization-row.js +31 -0
- package/dist/components/auth/organization/organization-settings.d.ts +12 -0
- package/dist/components/auth/organization/organization-settings.js +13 -0
- package/dist/components/auth/organization/organization-switcher.d.ts +20 -0
- package/dist/components/auth/organization/organization-switcher.js +48 -0
- package/dist/components/auth/organization/organization-view-skeleton.d.ts +6 -0
- package/dist/components/auth/organization/organization-view-skeleton.js +9 -0
- package/dist/components/auth/organization/organization-view.d.ts +15 -0
- package/dist/components/auth/organization/organization-view.js +31 -0
- package/dist/components/auth/organization/organization.d.ts +17 -0
- package/dist/components/auth/organization/organization.js +60 -0
- package/dist/components/auth/organization/organizations-empty.d.ts +4 -0
- package/dist/components/auth/organization/organizations-empty.js +9 -0
- package/dist/components/auth/organization/organizations-settings.d.ts +17 -0
- package/dist/components/auth/organization/organizations-settings.js +17 -0
- package/dist/components/auth/organization/organizations.d.ts +10 -0
- package/dist/components/auth/organization/organizations.js +21 -0
- package/dist/components/auth/organization/remove-member-dialog.d.ts +9 -0
- package/dist/components/auth/organization/remove-member-dialog.js +20 -0
- package/dist/components/auth/organization/slug-field.d.ts +19 -0
- package/dist/components/auth/organization/slug-field.js +38 -0
- package/dist/components/auth/organization/user-invitation-row-skeleton.d.ts +4 -0
- package/dist/components/auth/organization/user-invitation-row-skeleton.js +8 -0
- package/dist/components/auth/organization/user-invitation-row.d.ts +10 -0
- package/dist/components/auth/organization/user-invitation-row.js +22 -0
- package/dist/components/auth/organization/user-invitations-empty.d.ts +4 -0
- package/dist/components/auth/organization/user-invitations-empty.js +12 -0
- package/dist/components/auth/organization/user-invitations.d.ts +10 -0
- package/dist/components/auth/organization/user-invitations.js +18 -0
- package/dist/components/auth/passkey/add-passkey-dialog.js +21 -64
- package/dist/components/auth/passkey/delete-passkey-dialog.js +13 -46
- package/dist/components/auth/passkey/passkey-button.d.ts +1 -1
- package/dist/components/auth/passkey/passkey-button.js +24 -23
- package/dist/components/auth/passkey/passkey-skeleton.js +4 -16
- package/dist/components/auth/passkey/passkey.d.ts +1 -1
- package/dist/components/auth/passkey/passkey.js +16 -47
- package/dist/components/auth/passkey/passkeys-empty.js +8 -34
- package/dist/components/auth/passkey/passkeys.d.ts +1 -1
- package/dist/components/auth/passkey/passkeys.js +15 -41
- package/dist/components/auth/provider-button.d.ts +2 -2
- package/dist/components/auth/provider-button.js +28 -24
- package/dist/components/auth/provider-buttons.js +28 -18
- package/dist/components/auth/reset-password.d.ts +1 -1
- package/dist/components/auth/reset-password.js +56 -146
- package/dist/components/auth/settings/account/account-settings.d.ts +2 -2
- package/dist/components/auth/settings/account/account-settings.js +21 -19
- package/dist/components/auth/settings/account/change-avatar.js +53 -88
- package/dist/components/auth/settings/account/change-email.d.ts +1 -1
- package/dist/components/auth/settings/account/change-email.js +27 -53
- package/dist/components/auth/settings/account/user-profile.d.ts +1 -1
- package/dist/components/auth/settings/account/user-profile.js +64 -85
- package/dist/components/auth/settings/security/active-session.d.ts +1 -1
- package/dist/components/auth/settings/security/active-session.js +50 -57
- package/dist/components/auth/settings/security/active-sessions.d.ts +1 -1
- package/dist/components/auth/settings/security/active-sessions.js +21 -32
- package/dist/components/auth/settings/security/change-password.d.ts +1 -1
- package/dist/components/auth/settings/security/change-password.js +76 -186
- package/dist/components/auth/settings/security/linked-account.d.ts +1 -1
- package/dist/components/auth/settings/security/linked-account.js +37 -55
- package/dist/components/auth/settings/security/linked-accounts.d.ts +1 -1
- package/dist/components/auth/settings/security/linked-accounts.js +34 -43
- package/dist/components/auth/settings/security/security-settings.d.ts +2 -2
- package/dist/components/auth/settings/security/security-settings.js +19 -21
- package/dist/components/auth/settings/settings.d.ts +4 -4
- package/dist/components/auth/settings/settings.js +52 -44
- package/dist/components/auth/sign-in.d.ts +2 -2
- package/dist/components/auth/sign-in.js +63 -132
- package/dist/components/auth/sign-out.js +32 -26
- package/dist/components/auth/sign-up.d.ts +2 -2
- package/dist/components/auth/sign-up.js +97 -211
- package/dist/components/auth/theme/appearance.d.ts +1 -1
- package/dist/components/auth/theme/appearance.js +23 -71
- package/dist/components/auth/theme/theme-toggle-item.js +56 -61
- package/dist/components/auth/user/user-avatar.d.ts +4 -4
- package/dist/components/auth/user/user-avatar.js +31 -28
- package/dist/components/auth/user/user-button.d.ts +6 -7
- package/dist/components/auth/user/user-button.js +38 -72
- package/dist/components/auth/user/user-view.d.ts +13 -7
- package/dist/components/auth/user/user-view.js +26 -36
- package/dist/components/auth/username/sign-in-username.d.ts +2 -2
- package/dist/components/auth/username/sign-in-username.js +87 -147
- package/dist/components/auth/username/username-field.d.ts +1 -1
- package/dist/components/auth/username/username-field.js +44 -52
- package/dist/email.d.ts +8 -7
- package/dist/email.js +8 -8
- package/dist/index.d.ts +21 -21
- package/dist/index.js +21 -22
- package/dist/lib/auth/api-key-plugin.d.ts +7 -4
- package/dist/lib/auth/api-key-plugin.js +12 -10
- package/dist/lib/auth/auth-plugin.d.ts +10 -6
- package/dist/lib/auth/auth-plugin.js +1 -0
- package/dist/lib/auth/delete-user-plugin.d.ts +6 -6
- package/dist/lib/auth/delete-user-plugin.js +6 -9
- package/dist/lib/auth/magic-link-plugin.d.ts +5 -5
- package/dist/lib/auth/magic-link-plugin.js +17 -12
- package/dist/lib/auth/multi-session-plugin.d.ts +5 -5
- package/dist/lib/auth/multi-session-plugin.js +8 -11
- package/dist/lib/auth/organization-plugin.d.ts +37 -0
- package/dist/lib/auth/organization-plugin.js +19 -0
- package/dist/lib/auth/passkey-plugin.d.ts +5 -5
- package/dist/lib/auth/passkey-plugin.js +8 -11
- package/dist/lib/auth/theme-plugin.d.ts +6 -6
- package/dist/lib/auth/theme-plugin.js +25 -22
- package/dist/lib/auth/username-plugin.d.ts +11 -11
- package/dist/lib/auth/username-plugin.js +18 -17
- package/dist/plugins.d.ts +46 -22
- package/dist/plugins.js +47 -22
- package/package.json +25 -19
- package/src/components/auth/api-key/api-key.tsx +25 -16
- package/src/components/auth/api-key/api-keys-empty.tsx +8 -4
- package/src/components/auth/api-key/api-keys.tsx +52 -14
- package/src/components/auth/api-key/create-api-key-dialog.tsx +15 -2
- package/src/components/auth/api-key/delete-api-key-dialog.tsx +10 -2
- package/src/components/auth/api-key/organization-api-keys.tsx +55 -0
- package/src/components/auth/delete-user/danger-zone.tsx +3 -3
- package/src/components/auth/delete-user/{delete-user.tsx → delete-account.tsx} +9 -9
- package/src/components/auth/email/organization-invitation-email.tsx +38 -0
- package/src/components/auth/error-toaster.tsx +28 -10
- package/src/components/auth/forgot-password.tsx +10 -2
- package/src/components/auth/multi-session/manage-accounts.tsx +1 -1
- package/src/components/auth/multi-session/switch-account-submenu-content.tsx +7 -2
- package/src/components/auth/multi-session/switch-account-submenu-item.tsx +4 -2
- package/src/components/auth/multi-session/switch-account-submenu.tsx +8 -4
- package/src/components/auth/organization/change-organization-logo.tsx +171 -0
- package/src/components/auth/organization/create-organization-dialog.tsx +133 -0
- package/src/components/auth/organization/delete-organization-dialog.tsx +97 -0
- package/src/components/auth/organization/delete-organization-skeleton.tsx +17 -0
- package/src/components/auth/organization/delete-organization.tsx +77 -0
- package/src/components/auth/organization/invite-member-dialog.tsx +177 -0
- package/src/components/auth/organization/leave-organization-dialog.tsx +95 -0
- package/src/components/auth/organization/leave-organization.tsx +59 -0
- package/src/components/auth/organization/organization-danger-zone.tsx +68 -0
- package/src/components/auth/organization/organization-invitation-row-skeleton.tsx +29 -0
- package/src/components/auth/organization/organization-invitation-row.tsx +97 -0
- package/src/components/auth/organization/organization-invitations-empty.tsx +39 -0
- package/src/components/auth/organization/organization-invitations.tsx +351 -0
- package/src/components/auth/organization/organization-logo.tsx +64 -0
- package/src/components/auth/organization/organization-member-row-skeleton.tsx +24 -0
- package/src/components/auth/organization/organization-member-row.tsx +157 -0
- package/src/components/auth/organization/organization-members.tsx +284 -0
- package/src/components/auth/organization/organization-people.tsx +26 -0
- package/src/components/auth/organization/organization-profile.tsx +141 -0
- package/src/components/auth/organization/organization-row.tsx +66 -0
- package/src/components/auth/organization/organization-settings.tsx +38 -0
- package/src/components/auth/organization/organization-switcher.tsx +233 -0
- package/src/components/auth/organization/organization-view-skeleton.tsx +36 -0
- package/src/components/auth/organization/organization-view.tsx +109 -0
- package/src/components/auth/organization/organization.tsx +162 -0
- package/src/components/auth/organization/organizations-empty.tsx +35 -0
- package/src/components/auth/organization/organizations-settings.tsx +36 -0
- package/src/components/auth/organization/organizations.tsx +80 -0
- package/src/components/auth/organization/remove-member-dialog.tsx +95 -0
- package/src/components/auth/organization/slug-field.tsx +111 -0
- package/src/components/auth/organization/user-invitation-row-skeleton.tsx +17 -0
- package/src/components/auth/organization/user-invitation-row.tsx +90 -0
- package/src/components/auth/organization/user-invitations-empty.tsx +30 -0
- package/src/components/auth/organization/user-invitations.tsx +59 -0
- package/src/components/auth/settings/account/change-email.tsx +1 -1
- package/src/components/auth/settings/account/user-profile.tsx +5 -5
- package/src/components/auth/settings/security/active-sessions.tsx +6 -4
- package/src/components/auth/settings/security/linked-accounts.tsx +2 -2
- package/src/components/auth/settings/settings.tsx +77 -14
- package/src/components/auth/user/user-avatar.tsx +4 -1
- package/src/components/auth/user/user-button.tsx +14 -11
- package/src/components/auth/user/user-view.tsx +32 -12
- package/src/email.ts +1 -0
- package/src/lib/auth/api-key-plugin.ts +10 -4
- package/src/lib/auth/auth-plugin.ts +6 -1
- package/src/lib/auth/organization-plugin.tsx +32 -0
- package/src/plugins.ts +25 -1
- package/dist/components/auth/delete-user/delete-user.d.ts +0 -9
- package/dist/components/auth/delete-user/delete-user.js +0 -95
|
@@ -1,189 +1,79 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useChangePassword, useListAccounts, useRequestPasswordReset, useSession } from "@better-auth-ui/react";
|
|
3
|
+
import { Eye, EyeSlash } from "@gravity-ui/icons";
|
|
4
|
+
import { Button, Card, cn, FieldError, Fieldset, Form, Input, InputGroup, Label, Skeleton, Spinner, TextField, toast } from "@heroui/react";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
/**
|
|
7
|
+
* Render a card form for changing the authenticated user's password.
|
|
8
|
+
*
|
|
9
|
+
* When the user has a credential account, displays fields for current password,
|
|
10
|
+
* new password, and optionally confirm password. When the user only has social
|
|
11
|
+
* accounts, displays a prompt to set a password via the reset flow.
|
|
12
|
+
*
|
|
13
|
+
* @returns A JSX element containing the change-password or set-password card
|
|
14
|
+
*/
|
|
15
|
+
export function ChangePassword({ className, variant, ...props }) {
|
|
16
|
+
const { authClient, emailAndPassword, localization } = useAuth();
|
|
17
|
+
const { data: session } = useSession(authClient);
|
|
18
|
+
const { data: accounts, isPending: isAccountsPending } = useListAccounts(authClient);
|
|
19
|
+
const hasCredentialAccount = accounts?.some((account) => account.providerId === "credential");
|
|
20
|
+
if (!isAccountsPending && !hasCredentialAccount) {
|
|
21
|
+
return _jsx(SetPassword, { className: className, variant: variant, ...props });
|
|
22
|
+
}
|
|
23
|
+
return (_jsx(ChangePasswordForm, { className: className, variant: variant, emailAndPassword: emailAndPassword, localization: localization, session: isAccountsPending ? undefined : session, ...props }));
|
|
21
24
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
})] });
|
|
25
|
+
function SetPassword({ className, variant, ...props }) {
|
|
26
|
+
const { authClient, localization } = useAuth();
|
|
27
|
+
const { data: session } = useSession(authClient);
|
|
28
|
+
const { mutate: requestPasswordReset, isPending } = useRequestPasswordReset(authClient, {
|
|
29
|
+
onSuccess: () => toast.success(localization.auth.passwordResetEmailSent)
|
|
30
|
+
});
|
|
31
|
+
const handleSetPassword = () => {
|
|
32
|
+
if (!session?.user.email)
|
|
33
|
+
return;
|
|
34
|
+
requestPasswordReset({ email: session.user.email });
|
|
35
|
+
};
|
|
36
|
+
return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.changePassword }), _jsx(Card, { className: cn(className), variant: variant, ...props, children: _jsxs(Card.Content, { className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between", children: [_jsxs("div", { children: [_jsx("p", { className: "text-sm font-medium leading-tight", children: localization.settings.setPassword }), _jsx("p", { className: "text-muted text-xs mt-0.5", children: localization.settings.setPasswordDescription })] }), _jsxs(Button, { size: "sm", isPending: isPending, isDisabled: !session, onPress: handleSetPassword, children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.auth.sendResetLink] })] }) })] }));
|
|
53
37
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
})] });
|
|
38
|
+
function ChangePasswordForm({ className, variant, emailAndPassword, localization, session, ...props }) {
|
|
39
|
+
const { authClient } = useAuth();
|
|
40
|
+
const [currentPassword, setCurrentPassword] = useState("");
|
|
41
|
+
const [newPassword, setNewPassword] = useState("");
|
|
42
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
43
|
+
const { mutate: changePassword, isPending } = useChangePassword(authClient, {
|
|
44
|
+
onError: (error) => {
|
|
45
|
+
setCurrentPassword("");
|
|
46
|
+
setNewPassword("");
|
|
47
|
+
setConfirmPassword("");
|
|
48
|
+
toast.danger(error.error?.message || error.message);
|
|
49
|
+
},
|
|
50
|
+
onSuccess: () => {
|
|
51
|
+
setCurrentPassword("");
|
|
52
|
+
setNewPassword("");
|
|
53
|
+
setConfirmPassword("");
|
|
54
|
+
toast.success(localization.settings.changePasswordSuccess);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const [isNewPasswordVisible, setIsNewPasswordVisible] = useState(false);
|
|
58
|
+
const [isConfirmPasswordVisible, setIsConfirmPasswordVisible] = useState(false);
|
|
59
|
+
const handleSubmit = (e) => {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
if (emailAndPassword?.confirmPassword && newPassword !== confirmPassword) {
|
|
62
|
+
setCurrentPassword("");
|
|
63
|
+
setNewPassword("");
|
|
64
|
+
setConfirmPassword("");
|
|
65
|
+
toast.danger(localization.auth.passwordsDoNotMatch);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
changePassword({
|
|
69
|
+
currentPassword,
|
|
70
|
+
newPassword,
|
|
71
|
+
revokeOtherSessions: true
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.changePassword }), _jsx(Card, { className: cn("p-4 gap-4", className), variant: variant, ...props, children: _jsx(Card.Content, { children: _jsx(Form, { onSubmit: handleSubmit, children: _jsxs(Fieldset, { className: "w-full gap-4", children: [_jsxs(Fieldset.Group, { children: [_jsxs(TextField, { name: "currentPassword", type: "password", isDisabled: isPending || !session, defaultValue: "", value: currentPassword, onChange: setCurrentPassword, children: [_jsx(Label, { children: localization.settings.currentPassword }), _jsx(Input, { className: cn(!session && "hidden"), autoComplete: "current-password", placeholder: localization.settings.currentPasswordPlaceholder, required: true, variant: variant === "transparent" ? "primary" : "secondary" }), !session && (_jsx(Skeleton, { className: "h-10 md:h-9 w-full rounded-xl" })), _jsx(FieldError, {})] }), _jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, isDisabled: isPending || !session, value: newPassword, onChange: setNewPassword, children: [_jsx(Label, { children: localization.auth.newPassword }), _jsxs(InputGroup, { className: cn(!session && "hidden"), variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Input, { name: "newPassword", type: isNewPasswordVisible ? "text" : "password", autoComplete: "new-password", placeholder: localization.auth.newPasswordPlaceholder, required: true }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": isNewPasswordVisible
|
|
75
|
+
? localization.auth.hidePassword
|
|
76
|
+
: localization.auth.showPassword, size: "sm", variant: "ghost", onPress: () => setIsNewPasswordVisible(!isNewPasswordVisible), isDisabled: isPending, children: isNewPasswordVisible ? _jsx(EyeSlash, {}) : _jsx(Eye, {}) }) })] }), !session && (_jsx(Skeleton, { className: "h-10 md:h-9 w-full rounded-xl" })), _jsx(FieldError, {})] }), emailAndPassword?.confirmPassword && (_jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, isDisabled: isPending || !session, isRequired: true, value: confirmPassword, onChange: setConfirmPassword, children: [_jsx(Label, { children: localization.auth.confirmPassword }), _jsxs(InputGroup, { className: cn(!session && "hidden"), variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Input, { name: "confirmPassword", type: isConfirmPasswordVisible ? "text" : "password", autoComplete: "new-password", placeholder: localization.auth.confirmPasswordPlaceholder, required: true }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": isConfirmPasswordVisible
|
|
77
|
+
? localization.auth.hidePassword
|
|
78
|
+
: localization.auth.showPassword, size: "sm", variant: "ghost", onPress: () => setIsConfirmPasswordVisible(!isConfirmPasswordVisible), isDisabled: isPending, children: isConfirmPasswordVisible ? _jsx(EyeSlash, {}) : _jsx(Eye, {}) }) })] }), !session && (_jsx(Skeleton, { className: "h-10 md:h-9 w-full rounded-xl" })), _jsx(FieldError, {})] }))] }), _jsx(Fieldset.Actions, { children: _jsxs(Button, { type: "submit", isPending: isPending, isDisabled: !session, size: "sm", children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.settings.updatePassword] }) })] }) }) }) })] }));
|
|
187
79
|
}
|
|
188
|
-
//#endregion
|
|
189
|
-
export { C as ChangePassword };
|
|
@@ -1,56 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
});
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getProviderName } from "@better-auth-ui/core";
|
|
3
|
+
import { providerIcons, useAccountInfo, useAuth, useLinkSocial, useUnlinkAccount } from "@better-auth-ui/react";
|
|
4
|
+
import { Link, LinkSlash, PlugConnection } from "@gravity-ui/icons";
|
|
5
|
+
import { Button, cn, Skeleton, Spinner, toast } from "@heroui/react";
|
|
6
|
+
/**
|
|
7
|
+
* Render a single linked social account row with provider info and link/unlink control.
|
|
8
|
+
*
|
|
9
|
+
* Fetches additional account information from the provider using the accountInfo API
|
|
10
|
+
* and displays the provider name, account details, and a link/unlink button.
|
|
11
|
+
*
|
|
12
|
+
* @param account - The account object containing id, accountId, and providerId
|
|
13
|
+
* @param provider - The provider id
|
|
14
|
+
* @returns A JSX element containing the linked account row
|
|
15
|
+
*/
|
|
16
|
+
export function LinkedAccount({ account, provider }) {
|
|
17
|
+
const { authClient, baseURL, localization } = useAuth();
|
|
18
|
+
const { data: accountInfo, isPending: isLoadingInfo } = useAccountInfo(authClient, { query: { accountId: account?.accountId } });
|
|
19
|
+
const { mutate: linkSocial, isPending: isLinking } = useLinkSocial(authClient);
|
|
20
|
+
const { mutate: unlinkAccount, isPending: isUnlinking } = useUnlinkAccount(authClient, {
|
|
21
|
+
onSuccess: () => toast.success(localization.settings.accountUnlinked)
|
|
22
|
+
});
|
|
23
|
+
const ProviderIcon = providerIcons[provider];
|
|
24
|
+
const providerName = getProviderName(provider);
|
|
25
|
+
const displayName = accountInfo?.data?.login ||
|
|
26
|
+
accountInfo?.data?.username ||
|
|
27
|
+
accountInfo?.user?.email ||
|
|
28
|
+
accountInfo?.user?.name ||
|
|
29
|
+
account?.accountId;
|
|
30
|
+
return (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: cn("flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary"), children: ProviderIcon ? (_jsx(ProviderIcon, { className: "size-4.5" })) : (_jsx(PlugConnection, { className: "size-4.5" })) }), _jsxs("div", { className: "flex flex-col min-w-0", children: [_jsx("span", { className: "text-sm font-medium leading-tight", children: providerName }), account && isLoadingInfo ? (_jsx(Skeleton, { className: "h-3 w-24 my-0.5 rounded-lg" })) : (_jsx("span", { className: "text-xs text-muted truncate", children: account
|
|
31
|
+
? displayName
|
|
32
|
+
: localization.settings.linkProvider.replace("{{provider}}", providerName) }))] }), account ? (_jsxs(Button, { className: "ml-auto shrink-0", variant: "outline", size: "sm", onPress: () => unlinkAccount({ providerId: account.providerId }), isPending: isUnlinking, "aria-label": localization.settings.unlinkProvider.replace("{{provider}}", providerName), children: [isUnlinking ? _jsx(Spinner, { color: "current", size: "sm" }) : _jsx(LinkSlash, {}), localization.settings.unlinkProvider
|
|
33
|
+
.replace("{{provider}}", "")
|
|
34
|
+
.trim()] })) : (_jsxs(Button, { className: "ml-auto shrink-0", variant: "outline", size: "sm", onPress: () => linkSocial({
|
|
35
|
+
provider,
|
|
36
|
+
callbackURL: `${baseURL}${window.location.pathname}`
|
|
37
|
+
}), isPending: isLinking, "aria-label": localization.settings.linkProvider.replace("{{provider}}", providerName), children: [isLinking ? _jsx(Spinner, { color: "current", size: "sm" }) : _jsx(Link, {}), localization.settings.link] }))] }));
|
|
54
38
|
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { g as LinkedAccount };
|
|
@@ -1,45 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAuth
|
|
3
|
-
import { Card
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useListAccounts } from "@better-auth-ui/react";
|
|
3
|
+
import { Card, cn, Skeleton } from "@heroui/react";
|
|
4
|
+
import { LinkedAccount } from "./linked-account";
|
|
5
|
+
/**
|
|
6
|
+
* Render a card showing linked social accounts and available social providers to link.
|
|
7
|
+
*
|
|
8
|
+
* Linked accounts (excluding the "credential" provider) are shown with an unlink control;
|
|
9
|
+
* available providers are shown with a link control. Button states and labels reflect
|
|
10
|
+
* ongoing link/unlink activity and use localization for provider-specific text.
|
|
11
|
+
*
|
|
12
|
+
* @returns A JSX element containing the linked accounts card
|
|
13
|
+
*/
|
|
14
|
+
export function LinkedAccounts({ className, variant, ...props }) {
|
|
15
|
+
const { authClient, localization, socialProviders } = useAuth();
|
|
16
|
+
const { data: accounts, isPending } = useListAccounts(authClient);
|
|
17
|
+
const linkedAccounts = accounts?.filter((account) => account.providerId !== "credential");
|
|
18
|
+
const allRows = [
|
|
19
|
+
...(linkedAccounts?.map((account) => ({
|
|
20
|
+
key: account.id,
|
|
21
|
+
account,
|
|
22
|
+
provider: account.providerId
|
|
23
|
+
})) ?? []),
|
|
24
|
+
...(socialProviders?.map((provider) => ({
|
|
25
|
+
key: provider,
|
|
26
|
+
account: undefined,
|
|
27
|
+
provider
|
|
28
|
+
})) ?? [])
|
|
29
|
+
];
|
|
30
|
+
return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.linkedAccounts }), _jsx(Card, { className: cn(className), variant: variant, ...props, children: _jsx(Card.Content, { className: "gap-0", children: isPending
|
|
31
|
+
? socialProviders?.map((provider, index) => (_jsxs("div", { children: [index > 0 && (_jsx("div", { className: "border-b border-dashed -mx-4 my-4" })), _jsx(AccountRowSkeleton, {})] }, provider)))
|
|
32
|
+
: allRows.map((row, index) => (_jsxs("div", { children: [index > 0 && (_jsx("div", { className: "border-b border-dashed -mx-4 my-4" })), _jsx(LinkedAccount, { account: row.account, provider: row.provider })] }, row.key))) }) })] }));
|
|
31
33
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
className: "flex items-center justify-between",
|
|
35
|
-
children: /* @__PURE__ */ s("div", {
|
|
36
|
-
className: "flex items-center gap-3",
|
|
37
|
-
children: [/* @__PURE__ */ o(i, { className: "size-10 rounded-xl" }), /* @__PURE__ */ s("div", {
|
|
38
|
-
className: "flex flex-col gap-1",
|
|
39
|
-
children: [/* @__PURE__ */ o(i, { className: "h-4 w-20 rounded-lg" }), /* @__PURE__ */ o(i, { className: "h-3 w-32 rounded-lg" })]
|
|
40
|
-
})]
|
|
41
|
-
})
|
|
42
|
-
});
|
|
34
|
+
function AccountRowSkeleton() {
|
|
35
|
+
return (_jsx("div", { className: "flex items-center justify-between", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Skeleton, { className: "size-10 rounded-xl" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Skeleton, { className: "h-4 w-20 rounded-lg" }), _jsx(Skeleton, { className: "h-3 w-32 rounded-lg" })] })] }) }));
|
|
43
36
|
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { c as LinkedAccounts };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CardProps } from
|
|
2
|
-
import { ComponentProps } from
|
|
1
|
+
import { type CardProps } from "@heroui/react";
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
3
|
export type SecuritySettingsProps = {
|
|
4
4
|
className?: string;
|
|
5
5
|
variant?: CardProps["variant"];
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth } from "@better-auth-ui/react";
|
|
3
|
+
import { cn } from "@heroui/react";
|
|
4
|
+
import { ActiveSessions } from "./active-sessions";
|
|
5
|
+
import { ChangePassword } from "./change-password";
|
|
6
|
+
import { LinkedAccounts } from "./linked-accounts";
|
|
7
|
+
/**
|
|
8
|
+
* Renders the security settings layout including password management, linked accounts, and active sessions.
|
|
9
|
+
*
|
|
10
|
+
* ChangePassword is rendered when password authentication is enabled; LinkedAccounts is rendered when social providers are present.
|
|
11
|
+
* Each registered auth plugin may contribute `securityCards` (for example delete-user, passkeys).
|
|
12
|
+
*
|
|
13
|
+
* @param className - Optional additional CSS class names for the outer container.
|
|
14
|
+
* @param variant - Card variant forwarded to each security settings card.
|
|
15
|
+
* @returns The security settings container as a JSX element.
|
|
16
|
+
*/
|
|
17
|
+
export function SecuritySettings({ className, variant, ...props }) {
|
|
18
|
+
const { emailAndPassword, plugins, socialProviders } = useAuth();
|
|
19
|
+
return (_jsxs("div", { className: cn("flex w-full flex-col gap-4 md:gap-6", className), ...props, children: [emailAndPassword?.enabled && _jsx(ChangePassword, { variant: variant }), !!socialProviders?.length && _jsx(LinkedAccounts, { variant: variant }), _jsx(ActiveSessions, { variant: variant }), plugins.flatMap((plugin) => plugin.securityCards?.map((Card, index) => (_jsx(Card, { variant: variant }, `${plugin.id}-${index.toString()}`))))] }));
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { s as SecuritySettings };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SettingsView } from
|
|
2
|
-
import { CardProps } from
|
|
3
|
-
import { ComponentProps } from
|
|
1
|
+
import type { SettingsView } from "@better-auth-ui/core";
|
|
2
|
+
import { type CardProps } from "@heroui/react";
|
|
3
|
+
import { type ComponentProps } from "react";
|
|
4
4
|
export type SettingsProps = {
|
|
5
5
|
className?: string;
|
|
6
6
|
hideNav?: boolean;
|
|
@@ -19,6 +19,6 @@ export type SettingsProps = {
|
|
|
19
19
|
* @param variant - Card variant forwarded to each settings section card
|
|
20
20
|
* @returns A DOM tree containing the responsive settings tabs and the currently selected settings panel
|
|
21
21
|
*
|
|
22
|
-
* @throws Error if neither `view` nor `path` is provided
|
|
22
|
+
* @throws Error if neither `view` nor `path` is provided, or if `path` does not match any settings view
|
|
23
23
|
*/
|
|
24
24
|
export declare function Settings({ className, hideNav, path, variant, view, ...props }: SettingsProps & ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|