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-06-14 19:06:31 +02:00
|
|
|
|
2023-03-18 06:14:05 +01:00
|
|
|
export default function LoginUpdateProfile(props: PageProps<Extract<KcContext, { pageId: "login-update-profile.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
|
|
|
|
2022-10-13 11:58:31 +02:00
|
|
|
const { msg, msgStr } = i18n;
|
2022-09-27 21:30:33 +02:00
|
|
|
|
2022-10-13 11:58:31 +02:00
|
|
|
const { url, user, messagesPerField, isAppInitiatedAction } = kcContext;
|
2022-09-27 21:30:33 +02:00
|
|
|
|
2022-10-13 11:58:31 +02:00
|
|
|
return (
|
2023-03-21 02:36:13 +01:00
|
|
|
<Template {...{ kcContext, i18n, doUseDefaultCss, classes }} headerNode={msg("loginProfileTitle")}>
|
|
|
|
<form id="kc-update-profile-form" className={getClassName("kcFormClass")} action={url.loginAction} method="post">
|
|
|
|
{user.editUsernameAllowed && (
|
2023-03-18 06:14:05 +01:00
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
getClassName("kcFormGroupClass"),
|
2023-03-21 02:36:13 +01:00
|
|
|
messagesPerField.printIfExists("username", getClassName("kcFormGroupErrorClass"))
|
2023-03-18 06:14:05 +01:00
|
|
|
)}
|
|
|
|
>
|
|
|
|
<div className={getClassName("kcLabelWrapperClass")}>
|
2023-03-21 02:36:13 +01:00
|
|
|
<label htmlFor="username" className={getClassName("kcLabelClass")}>
|
|
|
|
{msg("username")}
|
2022-10-13 11:58:31 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
2023-03-18 06:14:05 +01:00
|
|
|
<div className={getClassName("kcInputWrapperClass")}>
|
2022-10-13 11:58:31 +02:00
|
|
|
<input
|
|
|
|
type="text"
|
2023-03-21 02:36:13 +01:00
|
|
|
id="username"
|
|
|
|
name="username"
|
|
|
|
defaultValue={user.username ?? ""}
|
2023-03-18 06:14:05 +01:00
|
|
|
className={getClassName("kcInputClass")}
|
2022-10-13 11:58:31 +02:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-03-21 02:36:13 +01:00
|
|
|
)}
|
2022-10-13 11:58:31 +02:00
|
|
|
|
2023-03-21 02:36:13 +01:00
|
|
|
<div
|
|
|
|
className={clsx(getClassName("kcFormGroupClass"), messagesPerField.printIfExists("email", getClassName("kcFormGroupErrorClass")))}
|
|
|
|
>
|
|
|
|
<div className={getClassName("kcLabelWrapperClass")}>
|
|
|
|
<label htmlFor="email" className={getClassName("kcLabelClass")}>
|
|
|
|
{msg("email")}
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div className={getClassName("kcInputWrapperClass")}>
|
|
|
|
<input type="text" id="email" name="email" defaultValue={user.email ?? ""} className={getClassName("kcInputClass")} />
|
2022-10-13 11:58:31 +02:00
|
|
|
</div>
|
2023-03-21 02:36:13 +01:00
|
|
|
</div>
|
2021-06-14 19:06:31 +02:00
|
|
|
|
2023-03-21 02:36:13 +01:00
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
getClassName("kcFormGroupClass"),
|
|
|
|
messagesPerField.printIfExists("firstName", getClassName("kcFormGroupErrorClass"))
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<div className={getClassName("kcLabelWrapperClass")}>
|
|
|
|
<label htmlFor="firstName" className={getClassName("kcLabelClass")}>
|
|
|
|
{msg("firstName")}
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div className={getClassName("kcInputWrapperClass")}>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="firstName"
|
|
|
|
name="firstName"
|
|
|
|
defaultValue={user.firstName ?? ""}
|
|
|
|
className={getClassName("kcInputClass")}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-13 11:58:31 +02:00
|
|
|
|
2023-03-21 02:36:13 +01:00
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
getClassName("kcFormGroupClass"),
|
|
|
|
messagesPerField.printIfExists("lastName", getClassName("kcFormGroupErrorClass"))
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<div className={getClassName("kcLabelWrapperClass")}>
|
|
|
|
<label htmlFor="lastName" className={getClassName("kcLabelClass")}>
|
|
|
|
{msg("lastName")}
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div className={getClassName("kcInputWrapperClass")}>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="lastName"
|
|
|
|
name="lastName"
|
|
|
|
defaultValue={user.lastName ?? ""}
|
|
|
|
className={getClassName("kcInputClass")}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={getClassName("kcFormGroupClass")}>
|
|
|
|
<div id="kc-form-options" className={getClassName("kcFormOptionsClass")}>
|
|
|
|
<div className={getClassName("kcFormOptionsWrapperClass")} />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="kc-form-buttons" className={getClassName("kcFormButtonsClass")}>
|
|
|
|
{isAppInitiatedAction ? (
|
|
|
|
<>
|
2022-10-13 11:58:31 +02:00
|
|
|
<input
|
2022-10-16 00:49:49 +02:00
|
|
|
className={clsx(
|
2023-03-18 06:14:05 +01:00
|
|
|
getClassName("kcButtonClass"),
|
|
|
|
getClassName("kcButtonPrimaryClass"),
|
|
|
|
getClassName("kcButtonLargeClass")
|
2022-10-13 11:58:31 +02:00
|
|
|
)}
|
|
|
|
type="submit"
|
|
|
|
defaultValue={msgStr("doSubmit")}
|
|
|
|
/>
|
2023-03-21 02:36:13 +01:00
|
|
|
<button
|
|
|
|
className={clsx(
|
|
|
|
getClassName("kcButtonClass"),
|
|
|
|
getClassName("kcButtonDefaultClass"),
|
|
|
|
getClassName("kcButtonLargeClass")
|
|
|
|
)}
|
|
|
|
type="submit"
|
|
|
|
name="cancel-aia"
|
|
|
|
value="true"
|
|
|
|
>
|
|
|
|
{msg("doCancel")}
|
|
|
|
</button>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<input
|
|
|
|
className={clsx(
|
|
|
|
getClassName("kcButtonClass"),
|
|
|
|
getClassName("kcButtonPrimaryClass"),
|
|
|
|
getClassName("kcButtonBlockClass"),
|
|
|
|
getClassName("kcButtonLargeClass")
|
|
|
|
)}
|
|
|
|
type="submit"
|
|
|
|
defaultValue={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
|
|
|
}
|