Dot not create fake attribute field, hide password confirm at an higher level

This commit is contained in:
Joseph Garrone 2024-04-22 04:06:06 +02:00
parent 8030bf42ff
commit f09ea971cf
2 changed files with 4 additions and 11 deletions

View File

@ -540,12 +540,6 @@ export type Attribute = {
validators: Validators; validators: Validators;
annotations: Record<string, string>; annotations: Record<string, string>;
multivalued?: boolean; multivalued?: boolean;
/**
* NOTE: This is not a Keycloak attribute, it's a Keycloakify addition.
* usecase is to enable to hide the password confirmation if the theme is configured like that.
* SEE: https://github.com/keycloakify/keycloakify/issues/238#issuecomment-1874605774
*/
hidden?: boolean;
autocomplete?: autocomplete?:
| "on" | "on"
| "off" | "off"

View File

@ -56,14 +56,14 @@ export type KcContextLike = {
passwordPolicies?: PasswordPolicies; passwordPolicies?: PasswordPolicies;
}; };
export type ParamsOfUseProfileAttributeForm = { export type ParamsOfUseUserProfileForm = {
kcContext: KcContextLike; kcContext: KcContextLike;
passwordValidators?: Validators; passwordValidators?: Validators;
requirePasswordConfirmation?: boolean; requirePasswordConfirmation?: boolean;
i18n: I18n; i18n: I18n;
}; };
export type ReturnTypeOfUseProfileAttributeForm = { export type ReturnTypeOfUseUserProfileForm = {
formState: FormState; formState: FormState;
dispatchFormAction: Dispatch<FormAction>; dispatchFormAction: Dispatch<FormAction>;
attributesWithPassword: Attribute[]; attributesWithPassword: Attribute[];
@ -73,8 +73,8 @@ export type ReturnTypeOfUseProfileAttributeForm = {
* NOTE: The attributesWithPassword returned is actually augmented with * NOTE: The attributesWithPassword returned is actually augmented with
* artificial password related attributes only if kcContext.passwordRequired === true * artificial password related attributes only if kcContext.passwordRequired === true
*/ */
export function useUserProfileForm(params: ParamsOfUseProfileAttributeForm): ReturnTypeOfUseProfileAttributeForm { export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTypeOfUseUserProfileForm {
const { kcContext, passwordValidators = {}, requirePasswordConfirmation = true, i18n } = params; const { kcContext, passwordValidators = {}, i18n } = params;
const attributesWithPassword = useMemo(() => { const attributesWithPassword = useMemo(() => {
const attributesWithPassword: Attribute[] = []; const attributesWithPassword: Attribute[] = [];
@ -118,7 +118,6 @@ export function useUserProfileForm(params: ParamsOfUseProfileAttributeForm): Ret
"annotations": {}, "annotations": {},
"html5DataAnnotations": {}, "html5DataAnnotations": {},
"autocomplete": "new-password", "autocomplete": "new-password",
"hidden": !requirePasswordConfirmation,
// NOTE: Compat with Keycloak version prior to 24 // NOTE: Compat with Keycloak version prior to 24
...({ "groupAnnotations": {} } as {}) ...({ "groupAnnotations": {} } as {})
} }