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

View File

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