Follow up on #827
This commit is contained in:
parent
137e12cbbb
commit
759b834ccc
@ -1,4 +1,4 @@
|
|||||||
import { Fragment, useCallback, useRef } from "react";
|
import { Fragment, useState } from "react";
|
||||||
import { getKcClsx } from "keycloakify/login/lib/kcClsx";
|
import { getKcClsx } from "keycloakify/login/lib/kcClsx";
|
||||||
import { kcSanitize } from "keycloakify/lib/kcSanitize";
|
import { kcSanitize } from "keycloakify/lib/kcSanitize";
|
||||||
import type { PageProps } from "keycloakify/login/pages/PageProps";
|
import type { PageProps } from "keycloakify/login/pages/PageProps";
|
||||||
@ -17,14 +17,7 @@ export default function LoginOtp(props: PageProps<Extract<KcContext, { pageId: "
|
|||||||
|
|
||||||
const { msg, msgStr } = i18n;
|
const { msg, msgStr } = i18n;
|
||||||
|
|
||||||
const loginButtonRef = useRef<HTMLInputElement>(null);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
const onSubmitForm = useCallback(() => {
|
|
||||||
if (loginButtonRef.current !== null) {
|
|
||||||
loginButtonRef.current.disabled = true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}, [loginButtonRef]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Template
|
<Template
|
||||||
@ -35,7 +28,16 @@ export default function LoginOtp(props: PageProps<Extract<KcContext, { pageId: "
|
|||||||
displayMessage={!messagesPerField.existsError("totp")}
|
displayMessage={!messagesPerField.existsError("totp")}
|
||||||
headerNode={msg("doLogIn")}
|
headerNode={msg("doLogIn")}
|
||||||
>
|
>
|
||||||
<form id="kc-otp-login-form" className={kcClsx("kcFormClass")} action={url.loginAction} onSubmit={onSubmitForm} method="post">
|
<form
|
||||||
|
id="kc-otp-login-form"
|
||||||
|
className={kcClsx("kcFormClass")}
|
||||||
|
action={url.loginAction}
|
||||||
|
onSubmit={() => {
|
||||||
|
setIsSubmitting(true);
|
||||||
|
return true;
|
||||||
|
}}
|
||||||
|
method="post"
|
||||||
|
>
|
||||||
{otpLogin.userOtpCredentials.length > 1 && (
|
{otpLogin.userOtpCredentials.length > 1 && (
|
||||||
<div className={kcClsx("kcFormGroupClass")}>
|
<div className={kcClsx("kcFormGroupClass")}>
|
||||||
<div className={kcClsx("kcInputWrapperClass")}>
|
<div className={kcClsx("kcInputWrapperClass")}>
|
||||||
@ -103,7 +105,7 @@ export default function LoginOtp(props: PageProps<Extract<KcContext, { pageId: "
|
|||||||
id="kc-login"
|
id="kc-login"
|
||||||
type="submit"
|
type="submit"
|
||||||
value={msgStr("doLogIn")}
|
value={msgStr("doLogIn")}
|
||||||
ref={loginButtonRef}
|
disabled={isSubmitting}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user