mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
fix admin local auth
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user