fix admin local auth

This commit is contained in:
dswbx
2025-12-03 17:41:25 +01:00
parent a39e76a440
commit 959dee013e
2 changed files with 12 additions and 6 deletions

View File

@@ -21,10 +21,13 @@ export type NativeFormProps = Omit<ComponentPropsWithoutRef<"form">, "onChange"
validateOn?: "change" | "submit";
errorFieldSelector?: (selector: string) => any | null;
reportValidity?: boolean;
onSubmit?: (data: any, ctx: { event: FormEvent<HTMLFormElement> }) => Promise<void> | void;
onSubmit?: (
data: any,
ctx: { event: FormEvent<HTMLFormElement>; form: HTMLFormElement },
) => Promise<void> | void;
onSubmitInvalid?: (
errors: InputError[],
ctx: { event: FormEvent<HTMLFormElement> },
ctx: { event: FormEvent<HTMLFormElement>; form: HTMLFormElement },
) => Promise<void> | void;
onError?: (errors: InputError[]) => void;
disableSubmitOnError?: boolean;
@@ -188,12 +191,12 @@ export function NativeForm({
const errors = validate({ report: true });
if (errors.length > 0) {
onSubmitInvalid?.(errors, { event: e });
onSubmitInvalid?.(errors, { event: e, form });
return;
}
if (onSubmit) {
await onSubmit(getFormValues(), { event: e });
await onSubmit(getFormValues(), { event: e, form });
} else {
form.submit();
}

View File

@@ -43,7 +43,10 @@ export function AuthForm({
}) as Record<string, AppAuthOAuthStrategy>;
const has_oauth = Object.keys(oauth).length > 0;
async function onSubmit(data: any, ctx: { event: FormEvent<HTMLFormElement> }) {
async function onSubmit(
data: any,
ctx: { event: FormEvent<HTMLFormElement>; form: HTMLFormElement },
) {
if ($auth?.local) {
ctx.event.preventDefault();
@@ -58,7 +61,7 @@ export function AuthForm({
await _onSubmit?.(ctx.event);
// submit form
ctx.event.currentTarget.submit();
ctx.form.submit();
}
useEffect(() => {