@softure-ai/auth 0.2.3 → 0.2.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/CHANGELOG.md +23 -0
- package/README.md +8 -2
- package/dist/index.js +1 -1
- package/dist/ui/auth-forms.d.ts +19 -6
- package/dist/ui/auth-forms.d.ts.map +1 -1
- package/dist/ui/auth-forms.js +64 -20
- package/dist/ui/auth-forms.js.map +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js.map +1 -1
- package/module.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/ui/auth-forms.tsx +129 -45
- package/src/ui/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,29 @@ Newest first. Each version lists what changed for an app that uses `@softure-ai/
|
|
|
4
4
|
production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
|
|
5
5
|
"Definition of done"). Versions before the first one below are described in their GitHub Releases (`auth@x.y.z`).
|
|
6
6
|
|
|
7
|
+
## 0.2.4
|
|
8
|
+
|
|
9
|
+
All additive (#588); existing calls keep their fields, names and look.
|
|
10
|
+
|
|
11
|
+
- `RegisterForm`'s consent box shows `errors.auth.consent_required` under the box when a submit finds it unticked,
|
|
12
|
+
instead of the browser's own bubble, and takes focus when it is the first invalid control; ticking it clears the
|
|
13
|
+
message. It takes `consentProps` (`{ id, classNames }`, `ConsentProps`), so with `id: "field-consent"` the box is
|
|
14
|
+
`#field-consent` and its error `#field-consent-error`.
|
|
15
|
+
- A server error for a field a form does not render (e.g. `consent` with `requireConsent={false}`) now shows as the
|
|
16
|
+
form error instead of being dropped.
|
|
17
|
+
- Every form takes `fieldClassNames` (ui's `InputFieldSlot`s: `label`, `hint`, `input`, ...), `fieldHintAs` and
|
|
18
|
+
`fieldHintProps`, passed to each of its text and password fields.
|
|
19
|
+
|
|
20
|
+
Migration for an app that turned the box off and rendered its own (`requireConsent={false}` plus a `CheckboxField`
|
|
21
|
+
in `extraFields`):
|
|
22
|
+
|
|
23
|
+
1. Drop `requireConsent={false}` and the app's consent box from `extraFields`; pass the statement as `consentLabel`.
|
|
24
|
+
2. Pass `consentProps={{ id: "field-consent" }}` (the id the app's tests use) and the box's classes in
|
|
25
|
+
`consentProps.classNames`.
|
|
26
|
+
3. Pass the app's field look as `fieldClassNames` (e.g. `{ label: "…" }`) and, for "?" hints, `fieldHintAs="tooltip"`
|
|
27
|
+
with `fieldHintProps`.
|
|
28
|
+
4. An app with its own translation already has `errors.auth.consent_required`; its wording is the box's message.
|
|
29
|
+
|
|
7
30
|
## 0.2.3
|
|
8
31
|
|
|
9
32
|
- `createCreateAccountScript(config, { maxAccounts?, alphabet?, clock? })` in `@softure-ai/auth/scripts` (#521): the
|
package/README.md
CHANGED
|
@@ -503,7 +503,10 @@ await runJobWorkerProcess({ config, handlers: { ...passwordResetJobHandlers, ...
|
|
|
503
503
|
**Your own forms.** `@softure-ai/auth/ui` exports `LoginForm`, `RegisterForm`,
|
|
504
504
|
`ChangePasswordForm`, `ForgotPasswordForm` and `ResetPasswordForm`; pass them the actions from
|
|
505
505
|
`@softure-ai/auth/next`. `RegisterForm` takes `consentLabel` and `extraFields` like
|
|
506
|
-
`createRegisterPage
|
|
506
|
+
`createRegisterPage`, and `consentProps` (`{ id, classNames }`) for the consent box: an unticked box shows
|
|
507
|
+
`errors.auth.consent_required` under it instead of the browser's bubble, and the server's consent error shows there
|
|
508
|
+
too. A field error for a field the form does not render (e.g. `consent` with `requireConsent={false}`) shows as the
|
|
509
|
+
form error.
|
|
507
510
|
|
|
508
511
|
**Tests.** `createTestAccount(db, { email, password, roles?, scrypt? })` from `@softure-ai/auth/testing`
|
|
509
512
|
writes an account and its role rows in one transaction, hashed as registration hashes it, and returns
|
|
@@ -628,7 +631,10 @@ Pages and forms are built from `@softure-ai/ui` (Card, fields, Checkbox, Button)
|
|
|
628
631
|
compiled classes, so `@softure-ai/ui/styles.css` styles them and the `--sft-*` tokens theme them.
|
|
629
632
|
Each form takes `classNames` for its slots (`root`, `form`, `footer`, `link`, `notice`, and `submit`
|
|
630
633
|
for the submit button's class), `submitVariant` (a `Button` variant, `primary` by default) and
|
|
631
|
-
`unstyled
|
|
634
|
+
`unstyled`. `fieldClassNames` (the ui field slots: `label`, `hint`, `input`, ...), `fieldHintAs` and
|
|
635
|
+
`fieldHintProps` go to every text and password field of the form, so its labels and hints match the app's other
|
|
636
|
+
forms; `RegisterForm`'s consent box takes its look from `consentProps.classNames`. Pages are server components you can
|
|
637
|
+
replace with your own page around the forms.
|
|
632
638
|
|
|
633
639
|
## 9. Copy
|
|
634
640
|
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ export const AUTH_RATE_LIMIT_BUCKETS = {
|
|
|
36
36
|
export const auth = defineModule({
|
|
37
37
|
manifest: {
|
|
38
38
|
id: MODULE_ID,
|
|
39
|
-
version: "0.2.
|
|
39
|
+
version: "0.2.4",
|
|
40
40
|
dependsOn: { security: "^0.2.0", mailing: "^0.2.0?", ops: "^0.2.0?", jobs: "^0.1.1?" },
|
|
41
41
|
dbSchema: "auth",
|
|
42
42
|
tables: ["users", "sessions", "user_roles", "password_resets"],
|
package/dist/ui/auth-forms.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Locale } from "@softure-ai/core";
|
|
2
|
-
import { type ButtonVariant, type ClassNames } from "@softure-ai/ui";
|
|
2
|
+
import { type ButtonVariant, type CheckboxSlot, type ClassNames, type HintAppearance, type HintPlacement, type InputFieldSlot } from "@softure-ai/ui";
|
|
3
3
|
import { type ReactNode } from "react";
|
|
4
4
|
import { type AuthFormState } from "../contract.js";
|
|
5
5
|
import { type AuthMessages } from "../messages/index.js";
|
|
@@ -14,6 +14,17 @@ interface AuthFormBaseProps {
|
|
|
14
14
|
readonly unstyled?: boolean;
|
|
15
15
|
/** The submit button's look; `primary` by default. Its class goes in `classNames.submit`. */
|
|
16
16
|
readonly submitVariant?: ButtonVariant;
|
|
17
|
+
/** Classes for every text and password field of the form (label, hint, input, ...), to match the app's other forms. */
|
|
18
|
+
readonly fieldClassNames?: ClassNames<InputFieldSlot>;
|
|
19
|
+
/** Where the fields show their hints: under the label (default) or behind a "?" tooltip. */
|
|
20
|
+
readonly fieldHintAs?: HintPlacement;
|
|
21
|
+
/** The tooltip hint's look for every field, so it matches the app's standalone hints. */
|
|
22
|
+
readonly fieldHintProps?: HintAppearance;
|
|
23
|
+
}
|
|
24
|
+
/** The consent box's own props: its id (e.g. for the app's tests) and its look. */
|
|
25
|
+
export interface ConsentProps {
|
|
26
|
+
readonly id?: string;
|
|
27
|
+
readonly classNames?: ClassNames<CheckboxSlot>;
|
|
17
28
|
}
|
|
18
29
|
export interface LoginFormProps extends AuthFormBaseProps {
|
|
19
30
|
/** Where to go after login; checked again on the server. */
|
|
@@ -25,7 +36,7 @@ export interface LoginFormProps extends AuthFormBaseProps {
|
|
|
25
36
|
/** A confirmation shown under the form, e.g. after a password reset. */
|
|
26
37
|
readonly notice?: string;
|
|
27
38
|
}
|
|
28
|
-
export declare function LoginForm(
|
|
39
|
+
export declare function LoginForm(props: LoginFormProps): import("react").JSX.Element;
|
|
29
40
|
export interface RegisterFormProps extends AuthFormBaseProps {
|
|
30
41
|
readonly next?: string;
|
|
31
42
|
readonly loginHref?: string;
|
|
@@ -35,30 +46,32 @@ export interface RegisterFormProps extends AuthFormBaseProps {
|
|
|
35
46
|
readonly minPasswordLength: number;
|
|
36
47
|
/** The consent statement; may contain links to the terms. Defaults to `messages.fields.consent`. */
|
|
37
48
|
readonly consentLabel?: ReactNode;
|
|
49
|
+
/** The consent box's id and look (`classNames` for its `CheckboxSlot`s). */
|
|
50
|
+
readonly consentProps?: ConsentProps;
|
|
38
51
|
/**
|
|
39
52
|
* The app's own inputs, before the consent checkbox. Their values reach `onRegistered` as
|
|
40
53
|
* `event.fields` when their names are declared in `auth({ registrationFields })`.
|
|
41
54
|
*/
|
|
42
55
|
readonly extraFields?: ReactNode;
|
|
43
56
|
}
|
|
44
|
-
export declare function RegisterForm(
|
|
57
|
+
export declare function RegisterForm(props: RegisterFormProps): import("react").JSX.Element;
|
|
45
58
|
export interface ChangePasswordFormProps extends AuthFormBaseProps {
|
|
46
59
|
readonly minPasswordLength: number;
|
|
47
60
|
}
|
|
48
|
-
export declare function ChangePasswordForm(
|
|
61
|
+
export declare function ChangePasswordForm(props: ChangePasswordFormProps): import("react").JSX.Element;
|
|
49
62
|
export interface ForgotPasswordFormProps extends AuthFormBaseProps {
|
|
50
63
|
/** How long a link works, for the confirmation. */
|
|
51
64
|
readonly ttlMinutes: number;
|
|
52
65
|
readonly loginHref?: string;
|
|
53
66
|
}
|
|
54
67
|
/** Asks for a reset link. Its confirmation is the same whether or not the email has an account. */
|
|
55
|
-
export declare function ForgotPasswordForm(
|
|
68
|
+
export declare function ForgotPasswordForm(props: ForgotPasswordFormProps): import("react").JSX.Element;
|
|
56
69
|
export interface ResetPasswordFormProps extends AuthFormBaseProps {
|
|
57
70
|
/** The token from the reset link; checked again on the server. */
|
|
58
71
|
readonly token: string;
|
|
59
72
|
readonly minPasswordLength: number;
|
|
60
73
|
}
|
|
61
74
|
/** Sets a new password from a reset link; its action goes to the login page on success. */
|
|
62
|
-
export declare function ResetPasswordForm(
|
|
75
|
+
export declare function ResetPasswordForm(props: ResetPasswordFormProps): import("react").JSX.Element;
|
|
63
76
|
export {};
|
|
64
77
|
//# sourceMappingURL=auth-forms.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-forms.d.ts","sourceRoot":"","sources":["../../src/ui/auth-forms.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"auth-forms.d.ts","sourceRoot":"","sources":["../../src/ui/auth-forms.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK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SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,mGAAmG;AACnG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,+BAgDhE;AAED,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAED,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,+BA6B9D"}
|
package/dist/ui/auth-forms.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { formatMessage } from "@softure-ai/core";
|
|
4
|
-
import { Button, Checkbox, createSlotClassGetter, FormError, PasswordField, TextField } from "@softure-ai/ui";
|
|
5
|
-
import { useActionState } from "react";
|
|
4
|
+
import { Button, Checkbox, createSlotClassGetter, FormError, PasswordField, TextField, } from "@softure-ai/ui";
|
|
5
|
+
import { useActionState, useState } from "react";
|
|
6
6
|
import { INITIAL_AUTH_FORM_STATE } from "../contract.js";
|
|
7
7
|
import { getAuthErrorMessage } from "../messages/index.js";
|
|
8
|
+
/** The field props every form passes to each of its text and password fields. */
|
|
9
|
+
function getFieldLook({ fieldClassNames, fieldHintAs, fieldHintProps, unstyled, locale }) {
|
|
10
|
+
return { classNames: fieldClassNames, hintAs: fieldHintAs, hintProps: fieldHintProps, unstyled, locale };
|
|
11
|
+
}
|
|
8
12
|
const DEFAULT_CLASSES = {
|
|
9
13
|
root: "sft:flex sft:flex-col sft:gap-3 sft:font-sans",
|
|
10
14
|
form: "sft:flex sft:flex-col sft:gap-3",
|
|
@@ -14,54 +18,94 @@ const DEFAULT_CLASSES = {
|
|
|
14
18
|
// The button styles itself; the slot only carries the app's class.
|
|
15
19
|
submit: "",
|
|
16
20
|
};
|
|
17
|
-
/**
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The error of one field, or of the form when no field owns it or the form does not render that field
|
|
23
|
+
* (e.g. `consent` with the box left out), so a server error is never dropped.
|
|
24
|
+
*/
|
|
25
|
+
function useErrors(state, messages, renderedFields) {
|
|
19
26
|
const message = state.error === undefined ? undefined : getAuthErrorMessage(messages, state.error);
|
|
27
|
+
const isFieldRendered = state.field !== undefined && renderedFields.includes(state.field);
|
|
20
28
|
return {
|
|
21
29
|
at: (field) => (state.field === field ? message : undefined),
|
|
22
|
-
form:
|
|
30
|
+
form: isFieldRendered ? undefined : message,
|
|
23
31
|
};
|
|
24
32
|
}
|
|
33
|
+
/** The first control of `form` that fails its constraints, in document order. */
|
|
34
|
+
function getFirstInvalidControl(form) {
|
|
35
|
+
return Array.from(form.elements).find((element) => (element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) &&
|
|
36
|
+
!element.validity.valid);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A required consent box. An unticked box shows `requiredMessage` under it instead of the browser's bubble (as ui's
|
|
40
|
+
* `CheckboxField` in statement mode does) and takes focus when it is the form's first invalid control; the server's
|
|
41
|
+
* error shows there otherwise.
|
|
42
|
+
*/
|
|
43
|
+
function ConsentCheckbox({ label, requiredMessage, error, consentProps, unstyled, }) {
|
|
44
|
+
const [invalidMessage, setInvalidMessage] = useState(undefined);
|
|
45
|
+
function handleInvalid(event) {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
setInvalidMessage(requiredMessage);
|
|
48
|
+
const box = event.currentTarget;
|
|
49
|
+
const firstInvalid = box.form === null ? box : getFirstInvalidControl(box.form);
|
|
50
|
+
if (firstInvalid === box)
|
|
51
|
+
box.focus();
|
|
52
|
+
}
|
|
53
|
+
return (_jsx(Checkbox, { id: consentProps?.id, classNames: consentProps?.classNames, name: "consent", label: label, required: true, error: invalidMessage ?? error, onInvalid: handleInvalid, onChange: (event) => {
|
|
54
|
+
if (event.currentTarget.checked)
|
|
55
|
+
setInvalidMessage(undefined);
|
|
56
|
+
}, unstyled: unstyled }));
|
|
57
|
+
}
|
|
25
58
|
function FormShell({ formAction, isPending, submitLabel, pendingLabel, formError, footer, slot, unstyled, submitVariant = "primary", children, }) {
|
|
26
59
|
return (_jsxs("div", { className: slot("root"), children: [_jsxs("form", { action: formAction, className: slot("form"), children: [children, _jsx(FormError, { message: formError, unstyled: unstyled }), _jsx(Button, { type: "submit", variant: submitVariant, fullWidth: true, pending: isPending, classNames: { root: slot("submit") }, unstyled: unstyled, children: isPending ? pendingLabel : submitLabel })] }), footer] }));
|
|
27
60
|
}
|
|
28
|
-
export function LoginForm(
|
|
61
|
+
export function LoginForm(props) {
|
|
62
|
+
const { action, messages, next, registerHref, forgotPasswordHref, notice, classNames, unstyled, submitVariant } = props;
|
|
29
63
|
const [state, formAction, isPending] = useActionState(action, INITIAL_AUTH_FORM_STATE);
|
|
30
|
-
const errors = useErrors(state, messages);
|
|
64
|
+
const errors = useErrors(state, messages, ["email", "password"]);
|
|
65
|
+
const field = getFieldLook(props);
|
|
31
66
|
const slot = createSlotClassGetter({ defaults: DEFAULT_CLASSES, classNames, unstyled });
|
|
32
67
|
const footer = registerHref === undefined && forgotPasswordHref === undefined && notice === undefined ? undefined : (_jsxs(_Fragment, { children: [notice === undefined ? null : (_jsx("p", { role: "status", className: slot("notice"), children: notice })), forgotPasswordHref === undefined ? null : (_jsx("p", { className: slot("footer"), children: _jsx("a", { href: forgotPasswordHref, className: slot("link"), children: messages.login.forgotPassword }) })), registerHref === undefined ? null : (_jsxs("p", { className: slot("footer"), children: [messages.login.noAccount, " ", _jsx("a", { href: registerHref, className: slot("link"), children: messages.login.registerLink })] }))] }));
|
|
33
|
-
return (_jsxs(FormShell, { formAction: formAction, isPending: isPending, submitLabel: messages.login.submit, pendingLabel: messages.login.pending, formError: errors.form, footer: footer, slot: slot, unstyled: unstyled, submitVariant: submitVariant, children: [next === undefined ? null : _jsx("input", { type: "hidden", name: "next", value: next }), _jsx(TextField, { name: "email", type: "email", label: messages.fields.email, autoComplete: "email", required: true, defaultValue: state.email ?? "", error: errors.at("email"),
|
|
68
|
+
return (_jsxs(FormShell, { formAction: formAction, isPending: isPending, submitLabel: messages.login.submit, pendingLabel: messages.login.pending, formError: errors.form, footer: footer, slot: slot, unstyled: unstyled, submitVariant: submitVariant, children: [next === undefined ? null : _jsx("input", { type: "hidden", name: "next", value: next }), _jsx(TextField, { name: "email", type: "email", label: messages.fields.email, autoComplete: "email", required: true, defaultValue: state.email ?? "", error: errors.at("email"), ...field }), _jsx(PasswordField, { name: "password", label: messages.fields.password, autoComplete: "current-password", error: errors.at("password"), ...field })] }));
|
|
34
69
|
}
|
|
35
|
-
export function RegisterForm(
|
|
70
|
+
export function RegisterForm(props) {
|
|
71
|
+
const { action, messages, next, loginHref, requireConsent, minPasswordLength, consentLabel, consentProps, extraFields } = props;
|
|
72
|
+
const { classNames, unstyled, submitVariant } = props;
|
|
36
73
|
const [state, formAction, isPending] = useActionState(action, INITIAL_AUTH_FORM_STATE);
|
|
37
|
-
const errors = useErrors(state, messages);
|
|
74
|
+
const errors = useErrors(state, messages, requireConsent ? ["email", "password", "consent"] : ["email", "password"]);
|
|
75
|
+
const field = getFieldLook(props);
|
|
38
76
|
const slot = createSlotClassGetter({ defaults: DEFAULT_CLASSES, classNames, unstyled });
|
|
39
77
|
const footer = loginHref === undefined ? undefined : (_jsxs("p", { className: slot("footer"), children: [messages.register.hasAccount, " ", _jsx("a", { href: loginHref, className: slot("link"), children: messages.register.loginLink })] }));
|
|
40
|
-
return (_jsxs(FormShell, { formAction: formAction, isPending: isPending, submitLabel: messages.register.submit, pendingLabel: messages.register.pending, formError: errors.form, footer: footer, slot: slot, unstyled: unstyled, submitVariant: submitVariant, children: [next === undefined ? null : _jsx("input", { type: "hidden", name: "next", value: next }), _jsx(TextField, { name: "email", type: "email", label: messages.fields.email, autoComplete: "email", required: true, defaultValue: state.email ?? "", error: errors.at("email"),
|
|
78
|
+
return (_jsxs(FormShell, { formAction: formAction, isPending: isPending, submitLabel: messages.register.submit, pendingLabel: messages.register.pending, formError: errors.form, footer: footer, slot: slot, unstyled: unstyled, submitVariant: submitVariant, children: [next === undefined ? null : _jsx("input", { type: "hidden", name: "next", value: next }), _jsx(TextField, { name: "email", type: "email", label: messages.fields.email, autoComplete: "email", required: true, defaultValue: state.email ?? "", error: errors.at("email"), ...field }), _jsx(PasswordField, { name: "password", label: messages.fields.password, hint: formatMessage(messages.fields.newPasswordHint, { minLength: minPasswordLength }), autoComplete: "new-password", minLength: minPasswordLength, error: errors.at("password"), ...field }), extraFields, requireConsent ? (_jsx(ConsentCheckbox, { label: consentLabel ?? messages.fields.consent, requiredMessage: messages.errors.auth.consent_required, error: errors.at("consent"), consentProps: consentProps, unstyled: unstyled })) : null] }));
|
|
41
79
|
}
|
|
42
|
-
export function ChangePasswordForm(
|
|
80
|
+
export function ChangePasswordForm(props) {
|
|
81
|
+
const { action, messages, minPasswordLength, classNames, unstyled, submitVariant } = props;
|
|
43
82
|
const [state, formAction, isPending] = useActionState(action, INITIAL_AUTH_FORM_STATE);
|
|
44
|
-
const errors = useErrors(state, messages);
|
|
83
|
+
const errors = useErrors(state, messages, ["currentPassword", "newPassword"]);
|
|
84
|
+
const field = getFieldLook(props);
|
|
45
85
|
const slot = createSlotClassGetter({ defaults: DEFAULT_CLASSES, classNames, unstyled });
|
|
46
86
|
const notice = state.status === "ok" ? (_jsx("p", { role: "status", className: slot("notice"), children: messages.changePassword.success })) : undefined;
|
|
47
|
-
return (_jsxs(FormShell, { formAction: formAction, isPending: isPending, submitLabel: messages.changePassword.submit, pendingLabel: messages.changePassword.pending, formError: errors.form, footer: notice, slot: slot, unstyled: unstyled, submitVariant: submitVariant, children: [_jsx(PasswordField, { name: "currentPassword", label: messages.fields.currentPassword, autoComplete: "current-password", error: errors.at("currentPassword"),
|
|
87
|
+
return (_jsxs(FormShell, { formAction: formAction, isPending: isPending, submitLabel: messages.changePassword.submit, pendingLabel: messages.changePassword.pending, formError: errors.form, footer: notice, slot: slot, unstyled: unstyled, submitVariant: submitVariant, children: [_jsx(PasswordField, { name: "currentPassword", label: messages.fields.currentPassword, autoComplete: "current-password", error: errors.at("currentPassword"), ...field }), _jsx(PasswordField, { name: "newPassword", label: messages.fields.newPassword, hint: formatMessage(messages.fields.newPasswordHint, { minLength: minPasswordLength }), autoComplete: "new-password", minLength: minPasswordLength, error: errors.at("newPassword"), ...field })] }));
|
|
48
88
|
}
|
|
49
89
|
/** Asks for a reset link. Its confirmation is the same whether or not the email has an account. */
|
|
50
|
-
export function ForgotPasswordForm(
|
|
90
|
+
export function ForgotPasswordForm(props) {
|
|
91
|
+
const { action, messages, ttlMinutes, loginHref, classNames, unstyled, submitVariant } = props;
|
|
51
92
|
const [state, formAction, isPending] = useActionState(action, INITIAL_AUTH_FORM_STATE);
|
|
52
|
-
const errors = useErrors(state, messages);
|
|
93
|
+
const errors = useErrors(state, messages, ["email"]);
|
|
94
|
+
const field = getFieldLook(props);
|
|
53
95
|
const slot = createSlotClassGetter({ defaults: DEFAULT_CLASSES, classNames, unstyled });
|
|
54
96
|
const backToLogin = loginHref === undefined ? undefined : (_jsx("p", { className: slot("footer"), children: _jsx("a", { href: loginHref, className: slot("link"), children: messages.forgotPassword.backToLogin }) }));
|
|
55
97
|
if (state.status === "ok") {
|
|
56
98
|
return (_jsxs("div", { className: slot("root"), children: [_jsx("p", { role: "status", className: slot("notice"), children: formatMessage(messages.forgotPassword.sent, { ttlMinutes }) }), backToLogin] }));
|
|
57
99
|
}
|
|
58
|
-
return (_jsx(FormShell, { formAction: formAction, isPending: isPending, submitLabel: messages.forgotPassword.submit, pendingLabel: messages.forgotPassword.pending, formError: errors.form, footer: backToLogin, slot: slot, unstyled: unstyled, submitVariant: submitVariant, children: _jsx(TextField, { name: "email", type: "email", label: messages.fields.email, autoComplete: "email", required: true, defaultValue: state.email ?? "", error: errors.at("email"),
|
|
100
|
+
return (_jsx(FormShell, { formAction: formAction, isPending: isPending, submitLabel: messages.forgotPassword.submit, pendingLabel: messages.forgotPassword.pending, formError: errors.form, footer: backToLogin, slot: slot, unstyled: unstyled, submitVariant: submitVariant, children: _jsx(TextField, { name: "email", type: "email", label: messages.fields.email, autoComplete: "email", required: true, defaultValue: state.email ?? "", error: errors.at("email"), ...field }) }));
|
|
59
101
|
}
|
|
60
102
|
/** Sets a new password from a reset link; its action goes to the login page on success. */
|
|
61
|
-
export function ResetPasswordForm(
|
|
103
|
+
export function ResetPasswordForm(props) {
|
|
104
|
+
const { action, messages, token, minPasswordLength, classNames, unstyled, submitVariant } = props;
|
|
62
105
|
const [state, formAction, isPending] = useActionState(action, INITIAL_AUTH_FORM_STATE);
|
|
63
|
-
const errors = useErrors(state, messages);
|
|
106
|
+
const errors = useErrors(state, messages, ["newPassword"]);
|
|
107
|
+
const field = getFieldLook(props);
|
|
64
108
|
const slot = createSlotClassGetter({ defaults: DEFAULT_CLASSES, classNames, unstyled });
|
|
65
|
-
return (_jsxs(FormShell, { formAction: formAction, isPending: isPending, submitLabel: messages.resetPassword.submit, pendingLabel: messages.resetPassword.pending, formError: errors.form, slot: slot, unstyled: unstyled, submitVariant: submitVariant, children: [_jsx("input", { type: "hidden", name: "token", value: token }), _jsx(PasswordField, { name: "newPassword", label: messages.fields.newPassword, hint: formatMessage(messages.fields.newPasswordHint, { minLength: minPasswordLength }), autoComplete: "new-password", minLength: minPasswordLength, error: errors.at("newPassword"),
|
|
109
|
+
return (_jsxs(FormShell, { formAction: formAction, isPending: isPending, submitLabel: messages.resetPassword.submit, pendingLabel: messages.resetPassword.pending, formError: errors.form, slot: slot, unstyled: unstyled, submitVariant: submitVariant, children: [_jsx("input", { type: "hidden", name: "token", value: token }), _jsx(PasswordField, { name: "newPassword", label: messages.fields.newPassword, hint: formatMessage(messages.fields.newPasswordHint, { minLength: minPasswordLength }), autoComplete: "new-password", minLength: minPasswordLength, error: errors.at("newPassword"), ...field })] }));
|
|
66
110
|
}
|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MAAM,CAAC,WAAW,EAClC,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,EACtF,YAAY,EAAC,cAAc,EAC3B,SAAS,EAAE,iBAAiB,EAC5B,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,KAC3B,KAAK,GACT,IACQ,CACb,CAAC;AACJ,CAAC"}
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { type AuthFormAction, type AuthFormSlot, ChangePasswordForm, type ChangePasswordFormProps, ForgotPasswordForm, type ForgotPasswordFormProps, LoginForm, type LoginFormProps, RegisterForm, type RegisterFormProps, ResetPasswordForm, type ResetPasswordFormProps, } from "./auth-forms.js";
|
|
1
|
+
export { type AuthFormAction, type AuthFormSlot, ChangePasswordForm, type ChangePasswordFormProps, type ConsentProps, ForgotPasswordForm, type ForgotPasswordFormProps, LoginForm, type LoginFormProps, RegisterForm, type RegisterFormProps, ResetPasswordForm, type ResetPasswordFormProps, } from "./auth-forms.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,SAAS,EACT,KAAK,cAAc,EACnB,YAAY,EACZ,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,SAAS,EACT,KAAK,cAAc,EACnB,YAAY,EACZ,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,iBAAiB,CAAC"}
|
package/dist/ui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,6FAA6F;AAC7F,OAAO,EAGL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,6FAA6F;AAC7F,OAAO,EAGL,kBAAkB,EAGlB,kBAAkB,EAElB,SAAS,EAET,YAAY,EAEZ,iBAAiB,GAElB,MAAM,iBAAiB,CAAC"}
|
package/module.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "SOFTURE AI auth module: users, scrypt passwords, database sessions, register with consent, login, logout, password change, roles, a proxy route guard, pages and forms for Next.js, and a password reset sender over @softure-ai/mailing, sent in the request or by a background job through @softure-ai/jobs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/index.ts
CHANGED
|
@@ -42,7 +42,7 @@ export const AUTH_RATE_LIMIT_BUCKETS = {
|
|
|
42
42
|
export const auth = defineModule({
|
|
43
43
|
manifest: {
|
|
44
44
|
id: MODULE_ID,
|
|
45
|
-
version: "0.2.
|
|
45
|
+
version: "0.2.4",
|
|
46
46
|
dependsOn: { security: "^0.2.0", mailing: "^0.2.0?", ops: "^0.2.0?", jobs: "^0.1.1?" },
|
|
47
47
|
dbSchema: "auth",
|
|
48
48
|
tables: ["users", "sessions", "user_roles", "password_resets"],
|
package/src/ui/auth-forms.tsx
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { formatMessage, type Locale } from "@softure-ai/core";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
type ButtonVariant,
|
|
7
|
+
Checkbox,
|
|
8
|
+
type CheckboxSlot,
|
|
9
|
+
type ClassNames,
|
|
10
|
+
createSlotClassGetter,
|
|
11
|
+
FormError,
|
|
12
|
+
type HintAppearance,
|
|
13
|
+
type HintPlacement,
|
|
14
|
+
type InputFieldSlot,
|
|
15
|
+
PasswordField,
|
|
16
|
+
TextField,
|
|
17
|
+
} from "@softure-ai/ui";
|
|
18
|
+
import { type InvalidEvent, type ReactNode, useActionState, useState } from "react";
|
|
6
19
|
import { type AuthFormField, type AuthFormState, INITIAL_AUTH_FORM_STATE } from "../contract.js";
|
|
7
20
|
import { type AuthMessages, getAuthErrorMessage } from "../messages/index.js";
|
|
8
21
|
|
|
@@ -23,6 +36,17 @@ interface AuthFormBaseProps {
|
|
|
23
36
|
readonly unstyled?: boolean;
|
|
24
37
|
/** The submit button's look; `primary` by default. Its class goes in `classNames.submit`. */
|
|
25
38
|
readonly submitVariant?: ButtonVariant;
|
|
39
|
+
/** Classes for every text and password field of the form (label, hint, input, ...), to match the app's other forms. */
|
|
40
|
+
readonly fieldClassNames?: ClassNames<InputFieldSlot>;
|
|
41
|
+
/** Where the fields show their hints: under the label (default) or behind a "?" tooltip. */
|
|
42
|
+
readonly fieldHintAs?: HintPlacement;
|
|
43
|
+
/** The tooltip hint's look for every field, so it matches the app's standalone hints. */
|
|
44
|
+
readonly fieldHintProps?: HintAppearance;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The field props every form passes to each of its text and password fields. */
|
|
48
|
+
function getFieldLook({ fieldClassNames, fieldHintAs, fieldHintProps, unstyled, locale }: AuthFormBaseProps) {
|
|
49
|
+
return { classNames: fieldClassNames, hintAs: fieldHintAs, hintProps: fieldHintProps, unstyled, locale };
|
|
26
50
|
}
|
|
27
51
|
|
|
28
52
|
const DEFAULT_CLASSES: Readonly<Record<AuthFormSlot, string>> = {
|
|
@@ -35,15 +59,77 @@ const DEFAULT_CLASSES: Readonly<Record<AuthFormSlot, string>> = {
|
|
|
35
59
|
submit: "",
|
|
36
60
|
};
|
|
37
61
|
|
|
38
|
-
/**
|
|
39
|
-
|
|
62
|
+
/**
|
|
63
|
+
* The error of one field, or of the form when no field owns it or the form does not render that field
|
|
64
|
+
* (e.g. `consent` with the box left out), so a server error is never dropped.
|
|
65
|
+
*/
|
|
66
|
+
function useErrors(state: AuthFormState, messages: AuthMessages, renderedFields: readonly AuthFormField[]) {
|
|
40
67
|
const message = state.error === undefined ? undefined : getAuthErrorMessage(messages, state.error);
|
|
68
|
+
const isFieldRendered = state.field !== undefined && renderedFields.includes(state.field);
|
|
41
69
|
return {
|
|
42
70
|
at: (field: AuthFormField) => (state.field === field ? message : undefined),
|
|
43
|
-
form:
|
|
71
|
+
form: isFieldRendered ? undefined : message,
|
|
44
72
|
};
|
|
45
73
|
}
|
|
46
74
|
|
|
75
|
+
/** The consent box's own props: its id (e.g. for the app's tests) and its look. */
|
|
76
|
+
export interface ConsentProps {
|
|
77
|
+
readonly id?: string;
|
|
78
|
+
readonly classNames?: ClassNames<CheckboxSlot>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The first control of `form` that fails its constraints, in document order. */
|
|
82
|
+
function getFirstInvalidControl(form: HTMLFormElement): Element | undefined {
|
|
83
|
+
return Array.from(form.elements).find(
|
|
84
|
+
(element) =>
|
|
85
|
+
(element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) &&
|
|
86
|
+
!element.validity.valid,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A required consent box. An unticked box shows `requiredMessage` under it instead of the browser's bubble (as ui's
|
|
92
|
+
* `CheckboxField` in statement mode does) and takes focus when it is the form's first invalid control; the server's
|
|
93
|
+
* error shows there otherwise.
|
|
94
|
+
*/
|
|
95
|
+
function ConsentCheckbox({
|
|
96
|
+
label,
|
|
97
|
+
requiredMessage,
|
|
98
|
+
error,
|
|
99
|
+
consentProps,
|
|
100
|
+
unstyled,
|
|
101
|
+
}: {
|
|
102
|
+
label: ReactNode;
|
|
103
|
+
requiredMessage: string;
|
|
104
|
+
error: string | undefined;
|
|
105
|
+
consentProps: ConsentProps | undefined;
|
|
106
|
+
unstyled: boolean | undefined;
|
|
107
|
+
}) {
|
|
108
|
+
const [invalidMessage, setInvalidMessage] = useState<string | undefined>(undefined);
|
|
109
|
+
function handleInvalid(event: InvalidEvent<HTMLInputElement>) {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
setInvalidMessage(requiredMessage);
|
|
112
|
+
const box = event.currentTarget;
|
|
113
|
+
const firstInvalid = box.form === null ? box : getFirstInvalidControl(box.form);
|
|
114
|
+
if (firstInvalid === box) box.focus();
|
|
115
|
+
}
|
|
116
|
+
return (
|
|
117
|
+
<Checkbox
|
|
118
|
+
id={consentProps?.id}
|
|
119
|
+
classNames={consentProps?.classNames}
|
|
120
|
+
name="consent"
|
|
121
|
+
label={label}
|
|
122
|
+
required
|
|
123
|
+
error={invalidMessage ?? error}
|
|
124
|
+
onInvalid={handleInvalid}
|
|
125
|
+
onChange={(event) => {
|
|
126
|
+
if (event.currentTarget.checked) setInvalidMessage(undefined);
|
|
127
|
+
}}
|
|
128
|
+
unstyled={unstyled}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
47
133
|
function FormShell({
|
|
48
134
|
formAction,
|
|
49
135
|
isPending,
|
|
@@ -92,9 +178,11 @@ export interface LoginFormProps extends AuthFormBaseProps {
|
|
|
92
178
|
readonly notice?: string;
|
|
93
179
|
}
|
|
94
180
|
|
|
95
|
-
export function LoginForm(
|
|
181
|
+
export function LoginForm(props: LoginFormProps) {
|
|
182
|
+
const { action, messages, next, registerHref, forgotPasswordHref, notice, classNames, unstyled, submitVariant } = props;
|
|
96
183
|
const [state, formAction, isPending] = useActionState(action, INITIAL_AUTH_FORM_STATE);
|
|
97
|
-
const errors = useErrors(state, messages);
|
|
184
|
+
const errors = useErrors(state, messages, ["email", "password"]);
|
|
185
|
+
const field = getFieldLook(props);
|
|
98
186
|
const slot = createSlotClassGetter({ defaults: DEFAULT_CLASSES, classNames, unstyled });
|
|
99
187
|
const footer =
|
|
100
188
|
registerHref === undefined && forgotPasswordHref === undefined && notice === undefined ? undefined : (
|
|
@@ -142,16 +230,14 @@ export function LoginForm({ action, messages, locale, next, registerHref, forgot
|
|
|
142
230
|
required
|
|
143
231
|
defaultValue={state.email ?? ""}
|
|
144
232
|
error={errors.at("email")}
|
|
145
|
-
|
|
146
|
-
locale={locale}
|
|
233
|
+
{...field}
|
|
147
234
|
/>
|
|
148
235
|
<PasswordField
|
|
149
236
|
name="password"
|
|
150
237
|
label={messages.fields.password}
|
|
151
238
|
autoComplete="current-password"
|
|
152
239
|
error={errors.at("password")}
|
|
153
|
-
|
|
154
|
-
locale={locale}
|
|
240
|
+
{...field}
|
|
155
241
|
/>
|
|
156
242
|
</FormShell>
|
|
157
243
|
);
|
|
@@ -166,6 +252,8 @@ export interface RegisterFormProps extends AuthFormBaseProps {
|
|
|
166
252
|
readonly minPasswordLength: number;
|
|
167
253
|
/** The consent statement; may contain links to the terms. Defaults to `messages.fields.consent`. */
|
|
168
254
|
readonly consentLabel?: ReactNode;
|
|
255
|
+
/** The consent box's id and look (`classNames` for its `CheckboxSlot`s). */
|
|
256
|
+
readonly consentProps?: ConsentProps;
|
|
169
257
|
/**
|
|
170
258
|
* The app's own inputs, before the consent checkbox. Their values reach `onRegistered` as
|
|
171
259
|
* `event.fields` when their names are declared in `auth({ registrationFields })`.
|
|
@@ -173,22 +261,12 @@ export interface RegisterFormProps extends AuthFormBaseProps {
|
|
|
173
261
|
readonly extraFields?: ReactNode;
|
|
174
262
|
}
|
|
175
263
|
|
|
176
|
-
export function RegisterForm({
|
|
177
|
-
action,
|
|
178
|
-
|
|
179
|
-
locale,
|
|
180
|
-
next,
|
|
181
|
-
loginHref,
|
|
182
|
-
requireConsent,
|
|
183
|
-
minPasswordLength,
|
|
184
|
-
consentLabel,
|
|
185
|
-
extraFields,
|
|
186
|
-
classNames,
|
|
187
|
-
unstyled,
|
|
188
|
-
submitVariant,
|
|
189
|
-
}: RegisterFormProps) {
|
|
264
|
+
export function RegisterForm(props: RegisterFormProps) {
|
|
265
|
+
const { action, messages, next, loginHref, requireConsent, minPasswordLength, consentLabel, consentProps, extraFields } = props;
|
|
266
|
+
const { classNames, unstyled, submitVariant } = props;
|
|
190
267
|
const [state, formAction, isPending] = useActionState(action, INITIAL_AUTH_FORM_STATE);
|
|
191
|
-
const errors = useErrors(state, messages);
|
|
268
|
+
const errors = useErrors(state, messages, requireConsent ? ["email", "password", "consent"] : ["email", "password"]);
|
|
269
|
+
const field = getFieldLook(props);
|
|
192
270
|
const slot = createSlotClassGetter({ defaults: DEFAULT_CLASSES, classNames, unstyled });
|
|
193
271
|
const footer =
|
|
194
272
|
loginHref === undefined ? undefined : (
|
|
@@ -220,8 +298,7 @@ export function RegisterForm({
|
|
|
220
298
|
required
|
|
221
299
|
defaultValue={state.email ?? ""}
|
|
222
300
|
error={errors.at("email")}
|
|
223
|
-
|
|
224
|
-
locale={locale}
|
|
301
|
+
{...field}
|
|
225
302
|
/>
|
|
226
303
|
<PasswordField
|
|
227
304
|
name="password"
|
|
@@ -230,12 +307,17 @@ export function RegisterForm({
|
|
|
230
307
|
autoComplete="new-password"
|
|
231
308
|
minLength={minPasswordLength}
|
|
232
309
|
error={errors.at("password")}
|
|
233
|
-
|
|
234
|
-
locale={locale}
|
|
310
|
+
{...field}
|
|
235
311
|
/>
|
|
236
312
|
{extraFields}
|
|
237
313
|
{requireConsent ? (
|
|
238
|
-
<
|
|
314
|
+
<ConsentCheckbox
|
|
315
|
+
label={consentLabel ?? messages.fields.consent}
|
|
316
|
+
requiredMessage={messages.errors.auth.consent_required}
|
|
317
|
+
error={errors.at("consent")}
|
|
318
|
+
consentProps={consentProps}
|
|
319
|
+
unstyled={unstyled}
|
|
320
|
+
/>
|
|
239
321
|
) : null}
|
|
240
322
|
</FormShell>
|
|
241
323
|
);
|
|
@@ -245,9 +327,11 @@ export interface ChangePasswordFormProps extends AuthFormBaseProps {
|
|
|
245
327
|
readonly minPasswordLength: number;
|
|
246
328
|
}
|
|
247
329
|
|
|
248
|
-
export function ChangePasswordForm(
|
|
330
|
+
export function ChangePasswordForm(props: ChangePasswordFormProps) {
|
|
331
|
+
const { action, messages, minPasswordLength, classNames, unstyled, submitVariant } = props;
|
|
249
332
|
const [state, formAction, isPending] = useActionState(action, INITIAL_AUTH_FORM_STATE);
|
|
250
|
-
const errors = useErrors(state, messages);
|
|
333
|
+
const errors = useErrors(state, messages, ["currentPassword", "newPassword"]);
|
|
334
|
+
const field = getFieldLook(props);
|
|
251
335
|
const slot = createSlotClassGetter({ defaults: DEFAULT_CLASSES, classNames, unstyled });
|
|
252
336
|
const notice =
|
|
253
337
|
state.status === "ok" ? (
|
|
@@ -272,8 +356,7 @@ export function ChangePasswordForm({ action, messages, locale, minPasswordLength
|
|
|
272
356
|
label={messages.fields.currentPassword}
|
|
273
357
|
autoComplete="current-password"
|
|
274
358
|
error={errors.at("currentPassword")}
|
|
275
|
-
|
|
276
|
-
locale={locale}
|
|
359
|
+
{...field}
|
|
277
360
|
/>
|
|
278
361
|
<PasswordField
|
|
279
362
|
name="newPassword"
|
|
@@ -282,8 +365,7 @@ export function ChangePasswordForm({ action, messages, locale, minPasswordLength
|
|
|
282
365
|
autoComplete="new-password"
|
|
283
366
|
minLength={minPasswordLength}
|
|
284
367
|
error={errors.at("newPassword")}
|
|
285
|
-
|
|
286
|
-
locale={locale}
|
|
368
|
+
{...field}
|
|
287
369
|
/>
|
|
288
370
|
</FormShell>
|
|
289
371
|
);
|
|
@@ -296,9 +378,11 @@ export interface ForgotPasswordFormProps extends AuthFormBaseProps {
|
|
|
296
378
|
}
|
|
297
379
|
|
|
298
380
|
/** Asks for a reset link. Its confirmation is the same whether or not the email has an account. */
|
|
299
|
-
export function ForgotPasswordForm(
|
|
381
|
+
export function ForgotPasswordForm(props: ForgotPasswordFormProps) {
|
|
382
|
+
const { action, messages, ttlMinutes, loginHref, classNames, unstyled, submitVariant } = props;
|
|
300
383
|
const [state, formAction, isPending] = useActionState(action, INITIAL_AUTH_FORM_STATE);
|
|
301
|
-
const errors = useErrors(state, messages);
|
|
384
|
+
const errors = useErrors(state, messages, ["email"]);
|
|
385
|
+
const field = getFieldLook(props);
|
|
302
386
|
const slot = createSlotClassGetter({ defaults: DEFAULT_CLASSES, classNames, unstyled });
|
|
303
387
|
const backToLogin =
|
|
304
388
|
loginHref === undefined ? undefined : (
|
|
@@ -338,8 +422,7 @@ export function ForgotPasswordForm({ action, messages, locale, ttlMinutes, login
|
|
|
338
422
|
required
|
|
339
423
|
defaultValue={state.email ?? ""}
|
|
340
424
|
error={errors.at("email")}
|
|
341
|
-
|
|
342
|
-
locale={locale}
|
|
425
|
+
{...field}
|
|
343
426
|
/>
|
|
344
427
|
</FormShell>
|
|
345
428
|
);
|
|
@@ -352,9 +435,11 @@ export interface ResetPasswordFormProps extends AuthFormBaseProps {
|
|
|
352
435
|
}
|
|
353
436
|
|
|
354
437
|
/** Sets a new password from a reset link; its action goes to the login page on success. */
|
|
355
|
-
export function ResetPasswordForm(
|
|
438
|
+
export function ResetPasswordForm(props: ResetPasswordFormProps) {
|
|
439
|
+
const { action, messages, token, minPasswordLength, classNames, unstyled, submitVariant } = props;
|
|
356
440
|
const [state, formAction, isPending] = useActionState(action, INITIAL_AUTH_FORM_STATE);
|
|
357
|
-
const errors = useErrors(state, messages);
|
|
441
|
+
const errors = useErrors(state, messages, ["newPassword"]);
|
|
442
|
+
const field = getFieldLook(props);
|
|
358
443
|
const slot = createSlotClassGetter({ defaults: DEFAULT_CLASSES, classNames, unstyled });
|
|
359
444
|
return (
|
|
360
445
|
<FormShell
|
|
@@ -375,8 +460,7 @@ export function ResetPasswordForm({ action, messages, locale, token, minPassword
|
|
|
375
460
|
autoComplete="new-password"
|
|
376
461
|
minLength={minPasswordLength}
|
|
377
462
|
error={errors.at("newPassword")}
|
|
378
|
-
|
|
379
|
-
locale={locale}
|
|
463
|
+
{...field}
|
|
380
464
|
/>
|
|
381
465
|
</FormShell>
|
|
382
466
|
);
|