2023-03-18 06:14:05 +01:00
|
|
|
import { clsx } from "keycloakify/tools/clsx";
|
2023-03-21 05:27:31 +01:00
|
|
|
import type { PageProps } from "keycloakify/login/pages/PageProps";
|
|
|
|
import { useGetClassName } from "keycloakify/login/lib/useGetClassName";
|
2023-03-18 18:27:50 +01:00
|
|
|
import type { KcContext } from "../kcContext";
|
2023-03-18 18:54:33 +01:00
|
|
|
import type { I18n } from "../i18n";
|
2022-10-13 11:58:31 +02:00
|
|
|
|
2023-03-18 06:14:05 +01:00
|
|
|
export default function LoginOtp(props: PageProps<Extract<KcContext, { pageId: "login-otp.ftl" }>, I18n>) {
|
|
|
|
const { kcContext, i18n, doUseDefaultCss, Template, classes } = props;
|
|
|
|
|
|
|
|
const { getClassName } = useGetClassName({
|
2023-03-21 05:27:31 +01:00
|
|
|
doUseDefaultCss,
|
2023-03-18 06:14:05 +01:00
|
|
|
classes
|
|
|
|
});
|
2022-10-13 11:58:31 +02:00
|
|
|
|
|
|
|
const { otpLogin, url } = kcContext;
|
|
|
|
|
|
|
|
const { msg, msgStr } = i18n;
|
|
|
|
|
|
|
|
return (
|
2024-02-02 14:35:14 +02:00
|
|
|
<>
|
|
|
|
<style>
|
|
|
|
{`
|
|
|
|
input[type="radio"]:checked~label.kcSelectOTPListClass{
|
|
|
|
border: 2px solid #39a5dc;
|
|
|
|
}`}
|
|
|
|
</style>
|
|
|
|
<Template {...{ kcContext, i18n, doUseDefaultCss, classes }} headerNode={msg("doLogIn")}>
|
|
|
|
<form id="kc-otp-login-form" className={getClassName("kcFormClass")} action={url.loginAction} method="post">
|
|
|
|
{otpLogin.userOtpCredentials.length > 1 && (
|
|
|
|
<div className={getClassName("kcFormGroupClass")}>
|
|
|
|
<div className={getClassName("kcInputWrapperClass")}>
|
|
|
|
{otpLogin.userOtpCredentials.map((otpCredential, index) => (
|
|
|
|
<div key={otpCredential.id}>
|
|
|
|
<input
|
|
|
|
id={`kc-otp-credential-${index}`}
|
|
|
|
name="selectedCredentialId"
|
|
|
|
type="radio"
|
|
|
|
value={otpCredential.id}
|
|
|
|
style={{ display: "none" }}
|
|
|
|
/>
|
|
|
|
<label
|
|
|
|
htmlFor={`kc-otp-credential-${index}`}
|
|
|
|
key={otpCredential.id}
|
|
|
|
className={getClassName("kcSelectOTPListClass")}
|
|
|
|
>
|
|
|
|
<div className={getClassName("kcSelectOTPListItemClass")}>
|
|
|
|
<span className={getClassName("kcAuthenticatorOtpCircleClass")} />
|
|
|
|
<h2 className={getClassName("kcSelectOTPItemHeadingClass")}>{otpCredential.userLabel}</h2>
|
|
|
|
</div>
|
|
|
|
</label>
|
2023-03-21 02:36:13 +01:00
|
|
|
</div>
|
2024-02-02 14:35:14 +02:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div className={getClassName("kcFormGroupClass")}>
|
|
|
|
<div className={getClassName("kcLabelWrapperClass")}>
|
|
|
|
<label htmlFor="otp" className={getClassName("kcLabelClass")}>
|
|
|
|
{msg("loginOtpOneTime")}
|
|
|
|
</label>
|
2021-10-12 00:26:29 +02:00
|
|
|
</div>
|
2021-05-01 14:55:58 +02:00
|
|
|
|
2024-02-02 14:35:14 +02:00
|
|
|
<div className={getClassName("kcInputWrapperClass")}>
|
|
|
|
<input id="otp" name="otp" autoComplete="off" type="text" className={getClassName("kcInputClass")} autoFocus />
|
|
|
|
</div>
|
2023-03-21 02:36:13 +01:00
|
|
|
</div>
|
2021-10-12 00:26:29 +02:00
|
|
|
|
2024-02-02 14:35:14 +02:00
|
|
|
<div className={getClassName("kcFormGroupClass")}>
|
|
|
|
<div id="kc-form-options" className={getClassName("kcFormOptionsClass")}>
|
|
|
|
<div className={getClassName("kcFormOptionsWrapperClass")} />
|
|
|
|
</div>
|
2023-03-21 02:36:13 +01:00
|
|
|
|
2024-02-02 14:35:14 +02:00
|
|
|
<div id="kc-form-buttons" className={getClassName("kcFormButtonsClass")}>
|
|
|
|
<input
|
|
|
|
className={clsx(
|
|
|
|
getClassName("kcButtonClass"),
|
|
|
|
getClassName("kcButtonPrimaryClass"),
|
|
|
|
getClassName("kcButtonBlockClass"),
|
|
|
|
getClassName("kcButtonLargeClass")
|
|
|
|
)}
|
|
|
|
name="login"
|
|
|
|
id="kc-login"
|
|
|
|
type="submit"
|
|
|
|
value={msgStr("doLogIn")}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-03-21 02:36:13 +01:00
|
|
|
</div>
|
2024-02-02 14:35:14 +02:00
|
|
|
</form>
|
|
|
|
</Template>
|
|
|
|
</>
|
2022-10-13 11:58:31 +02:00
|
|
|
);
|
2023-02-25 18:11:23 +01:00
|
|
|
}
|