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";
|
2021-03-07 14:57:53 +01:00
|
|
|
|
2023-03-18 06:14:05 +01:00
|
|
|
export default function LoginResetPassword(props: PageProps<Extract<KcContext, { pageId: "login-reset-password.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
|
|
|
|
});
|
2021-08-20 17:03:50 +02:00
|
|
|
|
2024-05-11 17:17:35 +02:00
|
|
|
const { url, realm, auth, messagesPerField } = kcContext;
|
2021-08-20 17:03:50 +02:00
|
|
|
|
2022-10-13 11:58:31 +02:00
|
|
|
const { msg, msgStr } = i18n;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Template
|
2023-03-18 06:14:05 +01:00
|
|
|
{...{ kcContext, i18n, doUseDefaultCss, classes }}
|
2024-05-11 17:17:35 +02:00
|
|
|
displayInfo
|
|
|
|
displayMessage={!messagesPerField.existsError("username")}
|
|
|
|
infoNode={realm.duplicateEmailsAllowed ? msg("emailInstructionUsername") : msg("emailInstruction")}
|
2022-10-13 11:58:31 +02:00
|
|
|
headerNode={msg("emailForgotTitle")}
|
2023-03-21 02:36:13 +01:00
|
|
|
>
|
|
|
|
<form id="kc-reset-password-form" className={getClassName("kcFormClass")} action={url.loginAction} method="post">
|
|
|
|
<div className={getClassName("kcFormGroupClass")}>
|
|
|
|
<div className={getClassName("kcLabelWrapperClass")}>
|
|
|
|
<label htmlFor="username" className={getClassName("kcLabelClass")}>
|
|
|
|
{!realm.loginWithEmailAllowed
|
|
|
|
? msg("username")
|
|
|
|
: !realm.registrationEmailAsUsername
|
2024-05-20 19:30:15 +02:00
|
|
|
? msg("usernameOrEmail")
|
|
|
|
: msg("email")}
|
2023-03-21 02:36:13 +01:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div className={getClassName("kcInputWrapperClass")}>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="username"
|
|
|
|
name="username"
|
|
|
|
className={getClassName("kcInputClass")}
|
|
|
|
autoFocus
|
2024-05-11 17:17:35 +02:00
|
|
|
defaultValue={auth.attemptedUsername ?? ""}
|
|
|
|
aria-invalid={messagesPerField.existsError("username")}
|
2023-03-21 02:36:13 +01:00
|
|
|
/>
|
2024-05-11 17:17:35 +02:00
|
|
|
{messagesPerField.existsError("username") && (
|
|
|
|
<span id="input-error-username" className={getClassName("kcInputErrorMessageClass")} aria-live="polite">
|
|
|
|
{messagesPerField.get("username")}
|
|
|
|
</span>
|
|
|
|
)}
|
2022-10-13 11:58:31 +02:00
|
|
|
</div>
|
2023-03-21 02:36:13 +01:00
|
|
|
</div>
|
|
|
|
<div className={clsx(getClassName("kcFormGroupClass"), getClassName("kcFormSettingClass"))}>
|
|
|
|
<div id="kc-form-options" className={getClassName("kcFormOptionsClass")}>
|
|
|
|
<div className={getClassName("kcFormOptionsWrapperClass")}>
|
|
|
|
<span>
|
|
|
|
<a href={url.loginUrl}>{msg("backToLogin")}</a>
|
|
|
|
</span>
|
2022-10-13 11:58:31 +02:00
|
|
|
</div>
|
2023-03-21 02:36:13 +01:00
|
|
|
</div>
|
2021-03-07 14:57:53 +01:00
|
|
|
|
2023-03-21 02:36:13 +01:00
|
|
|
<div id="kc-form-buttons" className={getClassName("kcFormButtonsClass")}>
|
|
|
|
<input
|
|
|
|
className={clsx(
|
|
|
|
getClassName("kcButtonClass"),
|
|
|
|
getClassName("kcButtonPrimaryClass"),
|
|
|
|
getClassName("kcButtonBlockClass"),
|
|
|
|
getClassName("kcButtonLargeClass")
|
|
|
|
)}
|
|
|
|
type="submit"
|
|
|
|
value={msgStr("doSubmit")}
|
|
|
|
/>
|
2022-10-13 11:58:31 +02:00
|
|
|
</div>
|
2023-03-21 02:36:13 +01:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</Template>
|
2022-10-13 11:58:31 +02:00
|
|
|
);
|
2023-02-25 18:11:23 +01:00
|
|
|
}
|