import React, { useState } from "react"; import { clsx } from "../tools/clsx"; import { useConstCallback } from "../tools/useConstCallback"; import type { FormEventHandler } from "react"; import type { KcContextBase } from "../getKcContext/KcContextBase"; import type { PageProps } from "./shared/KcProps"; import type { I18nBase } from "../i18n"; export default function Login(props: PageProps) { const { kcContext, i18n, doFetchDefaultThemeResources = true, Template, ...kcProps } = props; const { social, realm, url, usernameEditDisabled, login, auth, registrationDisabled } = kcContext; const { msg, msgStr } = i18n; const [isLoginButtonDisabled, setIsLoginButtonDisabled] = useState(false); const onSubmit = useConstCallback>(e => { e.preventDefault(); setIsLoginButtonDisabled(true); const formElement = e.target as HTMLFormElement; //NOTE: Even if we login with email Keycloak expect username and password in //the POST request. formElement.querySelector("input[name='email']")?.setAttribute("name", "username"); formElement.submit(); }); return (