Update prettier configuration
This commit is contained in:
@ -41,13 +41,13 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
|
||||
}, []);
|
||||
|
||||
useSetClassName({
|
||||
"qualifiedName": "html",
|
||||
"className": getClassName("kcHtmlClass")
|
||||
qualifiedName: "html",
|
||||
className: getClassName("kcHtmlClass")
|
||||
});
|
||||
|
||||
useSetClassName({
|
||||
"qualifiedName": "body",
|
||||
"className": bodyClassName ?? getClassName("kcBodyClass")
|
||||
qualifiedName: "body",
|
||||
className: bodyClassName ?? getClassName("kcBodyClass")
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@ -63,7 +63,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
|
||||
}, []);
|
||||
|
||||
const { areAllStyleSheetsLoaded } = useInsertLinkTags({
|
||||
"hrefs": !doUseDefaultCss
|
||||
hrefs: !doUseDefaultCss
|
||||
? []
|
||||
: [
|
||||
`${url.resourcesCommonPath}/node_modules/@patternfly/patternfly/patternfly.min.css`,
|
||||
@ -75,17 +75,17 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
|
||||
});
|
||||
|
||||
const { insertScriptTags } = useInsertScriptTags({
|
||||
"scriptTags": [
|
||||
scriptTags: [
|
||||
{
|
||||
"type": "module",
|
||||
"src": `${url.resourcesPath}/js/menu-button-links.js`
|
||||
type: "module",
|
||||
src: `${url.resourcesPath}/js/menu-button-links.js`
|
||||
},
|
||||
...(authenticationSession === undefined
|
||||
? []
|
||||
: [
|
||||
{
|
||||
"type": "module",
|
||||
"textContent": [
|
||||
type: "module",
|
||||
textContent: [
|
||||
`import { checkCookiesAndSetTimer } from "${url.resourcesPath}/js/authChecker.js";`,
|
||||
``,
|
||||
`checkCookiesAndSetTimer(`,
|
||||
@ -99,8 +99,8 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
|
||||
...scripts.map(
|
||||
script =>
|
||||
({
|
||||
"type": "text/javascript",
|
||||
"src": script
|
||||
type: "text/javascript",
|
||||
src: script
|
||||
} as const)
|
||||
)
|
||||
]
|
||||
@ -237,7 +237,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
|
||||
<span
|
||||
className={getClassName("kcAlertTitleClass")}
|
||||
dangerouslySetInnerHTML={{
|
||||
"__html": message.summary
|
||||
__html: message.summary
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
@ -2,7 +2,10 @@ import type { ReactNode } from "react";
|
||||
import type { KcContext } from "./kcContext";
|
||||
import type { I18n } from "./i18n";
|
||||
|
||||
export type TemplateProps<KcContext extends KcContext.Common, I18nExtended extends I18n> = {
|
||||
export type TemplateProps<
|
||||
KcContext extends KcContext.Common,
|
||||
I18nExtended extends I18n
|
||||
> = {
|
||||
kcContext: KcContext;
|
||||
i18n: I18nExtended;
|
||||
doUseDefaultCss: boolean;
|
||||
|
@ -43,7 +43,7 @@ export default function UserProfileFormFields(props: UserProfileFormFieldsProps)
|
||||
onIsFormSubmittableValueChange(isFormSubmittable);
|
||||
}, [isFormSubmittable]);
|
||||
|
||||
const groupNameRef = { "current": "" };
|
||||
const groupNameRef = { current: "" };
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -62,7 +62,9 @@ export default function UserProfileFormFields(props: UserProfileFormFieldsProps)
|
||||
)}
|
||||
<div
|
||||
className={getClassName("kcFormGroupClass")}
|
||||
style={{ "display": attribute.name === "password-confirm" && !doMakeUserConfirmPassword ? "none" : undefined }}
|
||||
style={{
|
||||
display: attribute.name === "password-confirm" && !doMakeUserConfirmPassword ? "none" : undefined
|
||||
}}
|
||||
>
|
||||
<div className={getClassName("kcLabelWrapperClass")}>
|
||||
<label htmlFor={attribute.name} className={getClassName("kcLabelClass")}>
|
||||
@ -342,9 +344,9 @@ function InputTag(props: InputFiledByTypeProps & { fieldIndex: number | undefine
|
||||
{...Object.fromEntries(Object.entries(attribute.html5DataAnnotations ?? {}).map(([key, value]) => [`data-${key}`, value]))}
|
||||
onChange={event =>
|
||||
formValidationDispatch({
|
||||
"action": "update",
|
||||
"name": attribute.name,
|
||||
"valueOrValues": (() => {
|
||||
action: "update",
|
||||
name: attribute.name,
|
||||
valueOrValues: (() => {
|
||||
if (fieldIndex !== undefined) {
|
||||
assert(valueOrValues instanceof Array);
|
||||
|
||||
@ -363,9 +365,9 @@ function InputTag(props: InputFiledByTypeProps & { fieldIndex: number | undefine
|
||||
}
|
||||
onBlur={() =>
|
||||
props.formValidationDispatch({
|
||||
"action": "focus lost",
|
||||
"name": attribute.name,
|
||||
"fieldIndex": fieldIndex
|
||||
action: "focus lost",
|
||||
name: attribute.name,
|
||||
fieldIndex: fieldIndex
|
||||
})
|
||||
}
|
||||
/>
|
||||
@ -484,9 +486,9 @@ function AddRemoveButtonsMultiValuedAttribute(props: {
|
||||
className="pf-c-button pf-m-inline pf-m-link"
|
||||
onClick={() =>
|
||||
dispatchFormAction({
|
||||
"action": "update",
|
||||
"name": attribute.name,
|
||||
"valueOrValues": values.filter((_, i) => i !== fieldIndex)
|
||||
action: "update",
|
||||
name: attribute.name,
|
||||
valueOrValues: values.filter((_, i) => i !== fieldIndex)
|
||||
})
|
||||
}
|
||||
>
|
||||
@ -501,9 +503,9 @@ function AddRemoveButtonsMultiValuedAttribute(props: {
|
||||
className="pf-c-button pf-m-inline pf-m-link"
|
||||
onClick={() =>
|
||||
dispatchFormAction({
|
||||
"action": "update",
|
||||
"name": attribute.name,
|
||||
"valueOrValues": [...values, ""]
|
||||
action: "update",
|
||||
name: attribute.name,
|
||||
valueOrValues: [...values, ""]
|
||||
})
|
||||
}
|
||||
>
|
||||
@ -527,17 +529,17 @@ function InputTagSelects(props: InputFiledByTypeProps) {
|
||||
switch (inputType) {
|
||||
case "select-radiobuttons":
|
||||
return {
|
||||
"inputType": "radio",
|
||||
"classDiv": getClassName("kcInputClassRadio"),
|
||||
"classInput": getClassName("kcInputClassRadioInput"),
|
||||
"classLabel": getClassName("kcInputClassRadioLabel")
|
||||
inputType: "radio",
|
||||
classDiv: getClassName("kcInputClassRadio"),
|
||||
classInput: getClassName("kcInputClassRadioInput"),
|
||||
classLabel: getClassName("kcInputClassRadioLabel")
|
||||
};
|
||||
case "multiselect-checkboxes":
|
||||
return {
|
||||
"inputType": "checkbox",
|
||||
"classDiv": getClassName("kcInputClassCheckbox"),
|
||||
"classInput": getClassName("kcInputClassCheckboxInput"),
|
||||
"classLabel": getClassName("kcInputClassCheckboxLabel")
|
||||
inputType: "checkbox",
|
||||
classDiv: getClassName("kcInputClassCheckbox"),
|
||||
classInput: getClassName("kcInputClassCheckboxInput"),
|
||||
classLabel: getClassName("kcInputClassCheckboxLabel")
|
||||
};
|
||||
}
|
||||
})();
|
||||
@ -581,9 +583,9 @@ function InputTagSelects(props: InputFiledByTypeProps) {
|
||||
checked={valueOrValues.includes(option)}
|
||||
onChange={event =>
|
||||
formValidationDispatch({
|
||||
"action": "update",
|
||||
"name": attribute.name,
|
||||
"valueOrValues": (() => {
|
||||
action: "update",
|
||||
name: attribute.name,
|
||||
valueOrValues: (() => {
|
||||
const isChecked = event.target.checked;
|
||||
|
||||
if (valueOrValues instanceof Array) {
|
||||
@ -604,9 +606,9 @@ function InputTagSelects(props: InputFiledByTypeProps) {
|
||||
}
|
||||
onBlur={() =>
|
||||
formValidationDispatch({
|
||||
"action": "focus lost",
|
||||
"name": attribute.name,
|
||||
"fieldIndex": undefined
|
||||
action: "focus lost",
|
||||
name: attribute.name,
|
||||
fieldIndex: undefined
|
||||
})
|
||||
}
|
||||
/>
|
||||
@ -642,16 +644,16 @@ function TextareaTag(props: InputFiledByTypeProps) {
|
||||
value={value}
|
||||
onChange={event =>
|
||||
formValidationDispatch({
|
||||
"action": "update",
|
||||
"name": attribute.name,
|
||||
"valueOrValues": event.target.value
|
||||
action: "update",
|
||||
name: attribute.name,
|
||||
valueOrValues: event.target.value
|
||||
})
|
||||
}
|
||||
onBlur={() =>
|
||||
formValidationDispatch({
|
||||
"action": "focus lost",
|
||||
"name": attribute.name,
|
||||
"fieldIndex": undefined
|
||||
action: "focus lost",
|
||||
name: attribute.name,
|
||||
fieldIndex: undefined
|
||||
})
|
||||
}
|
||||
/>
|
||||
@ -677,9 +679,9 @@ function SelectTag(props: InputFiledByTypeProps) {
|
||||
value={valueOrValues}
|
||||
onChange={event =>
|
||||
formValidationDispatch({
|
||||
"action": "update",
|
||||
"name": attribute.name,
|
||||
"valueOrValues": (() => {
|
||||
action: "update",
|
||||
name: attribute.name,
|
||||
valueOrValues: (() => {
|
||||
if (isMultiple) {
|
||||
return Array.from(event.target.selectedOptions).map(option => option.value);
|
||||
}
|
||||
@ -690,9 +692,9 @@ function SelectTag(props: InputFiledByTypeProps) {
|
||||
}
|
||||
onBlur={() =>
|
||||
formValidationDispatch({
|
||||
"action": "focus lost",
|
||||
"name": attribute.name,
|
||||
"fieldIndex": undefined
|
||||
action: "focus lost",
|
||||
name: attribute.name,
|
||||
fieldIndex: undefined
|
||||
})
|
||||
}
|
||||
>
|
||||
|
@ -91,19 +91,19 @@ export function createUseI18n<ExtraMessageKey extends string = never>(extraMessa
|
||||
|
||||
setI18n({
|
||||
...createI18nTranslationFunctions({
|
||||
"fallbackMessages": {
|
||||
fallbackMessages: {
|
||||
...fallbackMessages,
|
||||
...(keycloakifyExtraMessages[fallbackLanguageTag] ?? {}),
|
||||
...(extraMessages[fallbackLanguageTag] ?? {})
|
||||
} as any,
|
||||
"messages": {
|
||||
messages: {
|
||||
...(await getMessages(currentLanguageTag)),
|
||||
...((keycloakifyExtraMessages as any)[currentLanguageTag] ?? {}),
|
||||
...(extraMessages[currentLanguageTag] ?? {})
|
||||
} as any
|
||||
}),
|
||||
currentLanguageTag,
|
||||
"getChangeLocalUrl": newLanguageTag => {
|
||||
getChangeLocalUrl: newLanguageTag => {
|
||||
const { locale } = kcContext;
|
||||
|
||||
assert(locale !== undefined, "Internationalization not enabled");
|
||||
@ -114,7 +114,7 @@ export function createUseI18n<ExtraMessageKey extends string = never>(extraMessa
|
||||
|
||||
return targetSupportedLocale.url;
|
||||
},
|
||||
"labelBySupportedLanguageTag": Object.fromEntries(
|
||||
labelBySupportedLanguageTag: Object.fromEntries(
|
||||
(kcContext.locale?.supported ?? []).map(({ languageTag, label }) => [languageTag, label])
|
||||
)
|
||||
});
|
||||
@ -170,7 +170,7 @@ function createI18nTranslationFunctions<MessageKey extends string>(params: {
|
||||
})();
|
||||
|
||||
return doRenderMarkdown ? (
|
||||
<Markdown allowDangerousHtml renderers={{ "paragraph": "span" }}>
|
||||
<Markdown allowDangerousHtml renderers={{ paragraph: "span" }}>
|
||||
{messageWithArgsInjectedIfAny}
|
||||
</Markdown>
|
||||
) : (
|
||||
@ -186,7 +186,7 @@ function createI18nTranslationFunctions<MessageKey extends string>(params: {
|
||||
const keyUnwrappedFromCurlyBraces = match === null ? key : match[1];
|
||||
|
||||
const out = resolveMsg({
|
||||
"key": keyUnwrappedFromCurlyBraces,
|
||||
key: keyUnwrappedFromCurlyBraces,
|
||||
args,
|
||||
doRenderMarkdown
|
||||
});
|
||||
@ -195,38 +195,48 @@ function createI18nTranslationFunctions<MessageKey extends string>(params: {
|
||||
}
|
||||
|
||||
return {
|
||||
"msgStr": (key, ...args) => resolveMsg({ key, args, "doRenderMarkdown": false }) as string,
|
||||
"msg": (key, ...args) => resolveMsg({ key, args, "doRenderMarkdown": true }) as JSX.Element,
|
||||
"advancedMsg": (key, ...args) => resolveMsgAdvanced({ key, args, "doRenderMarkdown": true }) as JSX.Element,
|
||||
"advancedMsgStr": (key, ...args) => resolveMsgAdvanced({ key, args, "doRenderMarkdown": false }) as string
|
||||
msgStr: (key, ...args) => resolveMsg({ key, args, doRenderMarkdown: false }) as string,
|
||||
msg: (key, ...args) => resolveMsg({ key, args, doRenderMarkdown: true }) as JSX.Element,
|
||||
advancedMsg: (key, ...args) =>
|
||||
resolveMsgAdvanced({
|
||||
key,
|
||||
args,
|
||||
doRenderMarkdown: true
|
||||
}) as JSX.Element,
|
||||
advancedMsgStr: (key, ...args) =>
|
||||
resolveMsgAdvanced({
|
||||
key,
|
||||
args,
|
||||
doRenderMarkdown: false
|
||||
}) as string
|
||||
};
|
||||
}
|
||||
|
||||
const keycloakifyExtraMessages = {
|
||||
"en": {
|
||||
"shouldBeEqual": "{0} should be equal to {1}",
|
||||
"shouldBeDifferent": "{0} should be different to {1}",
|
||||
"shouldMatchPattern": "Pattern should match: `/{0}/`",
|
||||
"mustBeAnInteger": "Must be an integer",
|
||||
"notAValidOption": "Not a valid option",
|
||||
"selectAnOption": "Select an option",
|
||||
"remove": "Remove",
|
||||
"addValue": "Add value"
|
||||
en: {
|
||||
shouldBeEqual: "{0} should be equal to {1}",
|
||||
shouldBeDifferent: "{0} should be different to {1}",
|
||||
shouldMatchPattern: "Pattern should match: `/{0}/`",
|
||||
mustBeAnInteger: "Must be an integer",
|
||||
notAValidOption: "Not a valid option",
|
||||
selectAnOption: "Select an option",
|
||||
remove: "Remove",
|
||||
addValue: "Add value"
|
||||
},
|
||||
"fr": {
|
||||
fr: {
|
||||
/* spell-checker: disable */
|
||||
"shouldBeEqual": "{0} doit être égal à {1}",
|
||||
"shouldBeDifferent": "{0} doit être différent de {1}",
|
||||
"shouldMatchPattern": "Dois respecter le schéma: `/{0}/`",
|
||||
"mustBeAnInteger": "Doit être un nombre entier",
|
||||
"notAValidOption": "N'est pas une option valide",
|
||||
shouldBeEqual: "{0} doit être égal à {1}",
|
||||
shouldBeDifferent: "{0} doit être différent de {1}",
|
||||
shouldMatchPattern: "Dois respecter le schéma: `/{0}/`",
|
||||
mustBeAnInteger: "Doit être un nombre entier",
|
||||
notAValidOption: "N'est pas une option valide",
|
||||
|
||||
"logoutConfirmTitle": "Déconnexion",
|
||||
"logoutConfirmHeader": "Êtes-vous sûr(e) de vouloir vous déconnecter ?",
|
||||
"doLogout": "Se déconnecter",
|
||||
"selectAnOption": "Sélectionner une option",
|
||||
"remove": "Supprimer",
|
||||
"addValue": "Ajouter une valeur"
|
||||
logoutConfirmTitle: "Déconnexion",
|
||||
logoutConfirmHeader: "Êtes-vous sûr(e) de vouloir vous déconnecter ?",
|
||||
doLogout: "Se déconnecter",
|
||||
selectAnOption: "Sélectionner une option",
|
||||
remove: "Supprimer",
|
||||
addValue: "Ajouter une valeur"
|
||||
/* spell-checker: enable */
|
||||
}
|
||||
};
|
||||
|
@ -3,7 +3,10 @@ import { assert } from "tsafe/assert";
|
||||
import type { Equals } from "tsafe";
|
||||
import type { MessageKey } from "../i18n/i18n";
|
||||
|
||||
type ExtractAfterStartingWith<Prefix extends string, StrEnum> = StrEnum extends `${Prefix}${infer U}` ? U : never;
|
||||
type ExtractAfterStartingWith<
|
||||
Prefix extends string,
|
||||
StrEnum
|
||||
> = StrEnum extends `${Prefix}${infer U}` ? U : never;
|
||||
|
||||
/** Take theses type definition with a grain of salt.
|
||||
* Some values might be undefined on some pages.
|
||||
@ -103,7 +106,10 @@ export declare namespace KcContext {
|
||||
* @param text to return
|
||||
* @return text if message exists for given field, else undefined
|
||||
*/
|
||||
printIfExists: <T extends string>(fieldName: string, text: T) => T | undefined;
|
||||
printIfExists: <T extends string>(
|
||||
fieldName: string,
|
||||
text: T
|
||||
) => T | undefined;
|
||||
/**
|
||||
* Check if exists error message for given fields
|
||||
*
|
||||
|
@ -10,15 +10,23 @@ import type { ExtendKcContext } from "./getKcContextFromWindow";
|
||||
import { getKcContextFromWindow } from "./getKcContextFromWindow";
|
||||
import { symToStr } from "tsafe/symToStr";
|
||||
|
||||
export function createGetKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
||||
export function createGetKcContext<
|
||||
KcContextExtension extends { pageId: string } = never
|
||||
>(params?: {
|
||||
mockData?: readonly DeepPartial<ExtendKcContext<KcContextExtension>>[];
|
||||
mockProperties?: Record<string, string>;
|
||||
}) {
|
||||
const { mockData, mockProperties } = params ?? {};
|
||||
|
||||
function getKcContext<PageId extends ExtendKcContext<KcContextExtension>["pageId"] | undefined = undefined>(params?: {
|
||||
function getKcContext<
|
||||
PageId extends
|
||||
| ExtendKcContext<KcContextExtension>["pageId"]
|
||||
| undefined = undefined
|
||||
>(params?: {
|
||||
mockPageId?: PageId;
|
||||
storyPartialKcContext?: DeepPartial<Extract<ExtendKcContext<KcContextExtension>, { pageId: PageId }>>;
|
||||
storyPartialKcContext?: DeepPartial<
|
||||
Extract<ExtendKcContext<KcContextExtension>, { pageId: PageId }>
|
||||
>;
|
||||
}): {
|
||||
kcContext: PageId extends undefined
|
||||
? ExtendKcContext<KcContextExtension> | undefined
|
||||
@ -36,34 +44,46 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
||||
break warn_that_mock_is_enbaled;
|
||||
}
|
||||
|
||||
console.log(`%cKeycloakify: ${symToStr({ mockPageId })} set to ${mockPageId}.`, "background: red; color: yellow; font-size: medium");
|
||||
console.log(
|
||||
`%cKeycloakify: ${symToStr({
|
||||
mockPageId
|
||||
})} set to ${mockPageId}.`,
|
||||
"background: red; color: yellow; font-size: medium"
|
||||
);
|
||||
}
|
||||
|
||||
const kcContextDefaultMock = kcContextMocks.find(({ pageId }) => pageId === mockPageId);
|
||||
const kcContextDefaultMock = kcContextMocks.find(
|
||||
({ pageId }) => pageId === mockPageId
|
||||
);
|
||||
|
||||
const partialKcContextCustomMock = (() => {
|
||||
const out: DeepPartial<ExtendKcContext<KcContextExtension>> = {};
|
||||
|
||||
const mockDataPick = mockData?.find(({ pageId }) => pageId === mockPageId);
|
||||
const mockDataPick = mockData?.find(
|
||||
({ pageId }) => pageId === mockPageId
|
||||
);
|
||||
|
||||
if (mockDataPick !== undefined) {
|
||||
deepAssign({
|
||||
"target": out,
|
||||
"source": mockDataPick
|
||||
target: out,
|
||||
source: mockDataPick
|
||||
});
|
||||
}
|
||||
|
||||
if (storyPartialKcContext !== undefined) {
|
||||
deepAssign({
|
||||
"target": out,
|
||||
"source": storyPartialKcContext
|
||||
target: out,
|
||||
source: storyPartialKcContext
|
||||
});
|
||||
}
|
||||
|
||||
return Object.keys(out).length === 0 ? undefined : out;
|
||||
})();
|
||||
|
||||
if (kcContextDefaultMock === undefined && partialKcContextCustomMock === undefined) {
|
||||
if (
|
||||
kcContextDefaultMock === undefined &&
|
||||
partialKcContextCustomMock === undefined
|
||||
) {
|
||||
console.warn(
|
||||
[
|
||||
`WARNING: You declared the non build in page ${mockPageId} but you didn't `,
|
||||
@ -76,68 +96,95 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
||||
const kcContext: any = {};
|
||||
|
||||
deepAssign({
|
||||
"target": kcContext,
|
||||
"source": kcContextDefaultMock !== undefined ? kcContextDefaultMock : { "pageId": mockPageId, ...kcContextCommonMock }
|
||||
target: kcContext,
|
||||
source:
|
||||
kcContextDefaultMock !== undefined
|
||||
? kcContextDefaultMock
|
||||
: { pageId: mockPageId, ...kcContextCommonMock }
|
||||
});
|
||||
|
||||
if (partialKcContextCustomMock !== undefined) {
|
||||
deepAssign({
|
||||
"target": kcContext,
|
||||
"source": partialKcContextCustomMock
|
||||
target: kcContext,
|
||||
source: partialKcContextCustomMock
|
||||
});
|
||||
|
||||
if ("profile" in partialKcContextCustomMock) {
|
||||
assert(kcContextDefaultMock !== undefined && "profile" in kcContextDefaultMock);
|
||||
assert(
|
||||
kcContextDefaultMock !== undefined &&
|
||||
"profile" in kcContextDefaultMock
|
||||
);
|
||||
|
||||
const { attributes } = kcContextDefaultMock.profile;
|
||||
|
||||
id<KcContext.Register>(kcContext).profile.attributes = [];
|
||||
id<KcContext.Register>(kcContext).profile.attributesByName = {};
|
||||
|
||||
const partialAttributes = [...((partialKcContextCustomMock as DeepPartial<KcContext.Register>).profile?.attributes ?? [])].filter(
|
||||
exclude(undefined)
|
||||
);
|
||||
const partialAttributes = [
|
||||
...((
|
||||
partialKcContextCustomMock as DeepPartial<KcContext.Register>
|
||||
).profile?.attributes ?? [])
|
||||
].filter(exclude(undefined));
|
||||
|
||||
attributes.forEach(attribute => {
|
||||
const partialAttribute = partialAttributes.find(({ name }) => name === attribute.name);
|
||||
const partialAttribute = partialAttributes.find(
|
||||
({ name }) => name === attribute.name
|
||||
);
|
||||
|
||||
const augmentedAttribute: Attribute = {} as any;
|
||||
|
||||
deepAssign({
|
||||
"target": augmentedAttribute,
|
||||
"source": attribute
|
||||
target: augmentedAttribute,
|
||||
source: attribute
|
||||
});
|
||||
|
||||
if (partialAttribute !== undefined) {
|
||||
partialAttributes.splice(partialAttributes.indexOf(partialAttribute), 1);
|
||||
partialAttributes.splice(
|
||||
partialAttributes.indexOf(partialAttribute),
|
||||
1
|
||||
);
|
||||
|
||||
deepAssign({
|
||||
"target": augmentedAttribute,
|
||||
"source": partialAttribute
|
||||
target: augmentedAttribute,
|
||||
source: partialAttribute
|
||||
});
|
||||
}
|
||||
|
||||
id<KcContext.Register>(kcContext).profile.attributes.push(augmentedAttribute);
|
||||
id<KcContext.Register>(kcContext).profile.attributesByName[augmentedAttribute.name] = augmentedAttribute;
|
||||
id<KcContext.Register>(kcContext).profile.attributes.push(
|
||||
augmentedAttribute
|
||||
);
|
||||
id<KcContext.Register>(kcContext).profile.attributesByName[
|
||||
augmentedAttribute.name
|
||||
] = augmentedAttribute;
|
||||
});
|
||||
|
||||
partialAttributes
|
||||
.map(partialAttribute => ({ "validators": {}, ...partialAttribute }))
|
||||
.map(partialAttribute => ({
|
||||
validators: {},
|
||||
...partialAttribute
|
||||
}))
|
||||
.forEach(partialAttribute => {
|
||||
const { name } = partialAttribute;
|
||||
|
||||
assert(name !== undefined, "If you define a mock attribute it must have at least a name");
|
||||
assert(
|
||||
name !== undefined,
|
||||
"If you define a mock attribute it must have at least a name"
|
||||
);
|
||||
|
||||
id<KcContext.Register>(kcContext).profile.attributes.push(partialAttribute as any);
|
||||
id<KcContext.Register>(kcContext).profile.attributesByName[name] = partialAttribute as any;
|
||||
id<KcContext.Register>(kcContext).profile.attributes.push(
|
||||
partialAttribute as any
|
||||
);
|
||||
id<KcContext.Register>(kcContext).profile.attributesByName[
|
||||
name
|
||||
] = partialAttribute as any;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (mockProperties !== undefined) {
|
||||
deepAssign({
|
||||
"target": kcContext.properties,
|
||||
"source": mockProperties
|
||||
target: kcContext.properties,
|
||||
source: mockProperties
|
||||
});
|
||||
}
|
||||
|
||||
@ -145,14 +192,14 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
||||
}
|
||||
|
||||
if (realKcContext === undefined) {
|
||||
return { "kcContext": undefined as any };
|
||||
return { kcContext: undefined as any };
|
||||
}
|
||||
|
||||
if (realKcContext.themeType !== "login") {
|
||||
return { "kcContext": undefined as any };
|
||||
return { kcContext: undefined as any };
|
||||
}
|
||||
|
||||
return { "kcContext": realKcContext as any };
|
||||
return { kcContext: realKcContext as any };
|
||||
}
|
||||
|
||||
return { getKcContext };
|
||||
|
@ -5,7 +5,9 @@ import { createGetKcContext } from "./createGetKcContext";
|
||||
/** NOTE: We now recommend using createGetKcContext instead of this function to make storybook integration easier
|
||||
* See: https://github.com/keycloakify/keycloakify-starter/blob/main/src/keycloak-theme/account/kcContext.ts
|
||||
*/
|
||||
export function getKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
||||
export function getKcContext<
|
||||
KcContextExtension extends { pageId: string } = never
|
||||
>(params?: {
|
||||
mockPageId?: ExtendKcContext<KcContextExtension>["pageId"];
|
||||
mockData?: readonly DeepPartial<ExtendKcContext<KcContextExtension>>[];
|
||||
}): { kcContext: ExtendKcContext<KcContextExtension> | undefined } {
|
||||
|
@ -2,10 +2,14 @@ import type { KcContext } from "./KcContext";
|
||||
import type { AndByDiscriminatingKey } from "keycloakify/tools/AndByDiscriminatingKey";
|
||||
import { nameOfTheGlobal } from "keycloakify/bin/shared/constants";
|
||||
|
||||
export type ExtendKcContext<KcContextExtension extends { pageId: string }> = [KcContextExtension] extends [never]
|
||||
export type ExtendKcContext<KcContextExtension extends { pageId: string }> = [
|
||||
KcContextExtension
|
||||
] extends [never]
|
||||
? KcContext
|
||||
: AndByDiscriminatingKey<"pageId", KcContextExtension & KcContext.Common, KcContext>;
|
||||
|
||||
export function getKcContextFromWindow<KcContextExtension extends { pageId: string } = never>(): ExtendKcContext<KcContextExtension> | undefined {
|
||||
export function getKcContextFromWindow<
|
||||
KcContextExtension extends { pageId: string } = never
|
||||
>(): ExtendKcContext<KcContextExtension> | undefined {
|
||||
return typeof window === "undefined" ? undefined : (window as any)[nameOfTheGlobal];
|
||||
}
|
||||
|
@ -1,324 +1,336 @@
|
||||
import "minimal-polyfills/Object.fromEntries";
|
||||
import type { KcContext, Attribute } from "./KcContext";
|
||||
import { resources_common, keycloak_resources, type LoginThemePageId } from "keycloakify/bin/shared/constants";
|
||||
import {
|
||||
resources_common,
|
||||
keycloak_resources,
|
||||
type LoginThemePageId
|
||||
} from "keycloakify/bin/shared/constants";
|
||||
import { id } from "tsafe/id";
|
||||
import { assert, type Equals } from "tsafe/assert";
|
||||
import { BASE_URL } from "keycloakify/lib/BASE_URL";
|
||||
|
||||
const attributes: Attribute[] = [
|
||||
{
|
||||
"validators": {
|
||||
"length": {
|
||||
validators: {
|
||||
length: {
|
||||
"ignore.empty.value": true,
|
||||
"min": "3",
|
||||
"max": "255"
|
||||
min: "3",
|
||||
max: "255"
|
||||
}
|
||||
},
|
||||
"displayName": "${username}",
|
||||
"annotations": {},
|
||||
"required": true,
|
||||
"autocomplete": "username",
|
||||
"readOnly": false,
|
||||
"name": "username",
|
||||
"value": "xxxx"
|
||||
displayName: "${username}",
|
||||
annotations: {},
|
||||
required: true,
|
||||
autocomplete: "username",
|
||||
readOnly: false,
|
||||
name: "username",
|
||||
value: "xxxx"
|
||||
},
|
||||
{
|
||||
"validators": {
|
||||
"length": {
|
||||
"max": "255",
|
||||
validators: {
|
||||
length: {
|
||||
max: "255",
|
||||
"ignore.empty.value": true
|
||||
},
|
||||
"email": {
|
||||
email: {
|
||||
"ignore.empty.value": true
|
||||
},
|
||||
"pattern": {
|
||||
pattern: {
|
||||
"ignore.empty.value": true,
|
||||
"pattern": "gmail\\.com$"
|
||||
pattern: "gmail\\.com$"
|
||||
}
|
||||
},
|
||||
"displayName": "${email}",
|
||||
"annotations": {},
|
||||
"required": true,
|
||||
"autocomplete": "email",
|
||||
"readOnly": false,
|
||||
"name": "email"
|
||||
displayName: "${email}",
|
||||
annotations: {},
|
||||
required: true,
|
||||
autocomplete: "email",
|
||||
readOnly: false,
|
||||
name: "email"
|
||||
},
|
||||
{
|
||||
"validators": {
|
||||
"length": {
|
||||
"max": "255",
|
||||
validators: {
|
||||
length: {
|
||||
max: "255",
|
||||
"ignore.empty.value": true
|
||||
}
|
||||
},
|
||||
"displayName": "${firstName}",
|
||||
"annotations": {},
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"name": "firstName"
|
||||
displayName: "${firstName}",
|
||||
annotations: {},
|
||||
required: true,
|
||||
readOnly: false,
|
||||
name: "firstName"
|
||||
},
|
||||
{
|
||||
"validators": {
|
||||
"length": {
|
||||
"max": "255",
|
||||
validators: {
|
||||
length: {
|
||||
max: "255",
|
||||
"ignore.empty.value": true
|
||||
}
|
||||
},
|
||||
"displayName": "${lastName}",
|
||||
"annotations": {},
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"name": "lastName"
|
||||
displayName: "${lastName}",
|
||||
annotations: {},
|
||||
required: true,
|
||||
readOnly: false,
|
||||
name: "lastName"
|
||||
}
|
||||
];
|
||||
|
||||
const attributesByName = Object.fromEntries(attributes.map(attribute => [attribute.name, attribute])) as any;
|
||||
const attributesByName = Object.fromEntries(
|
||||
attributes.map(attribute => [attribute.name, attribute])
|
||||
) as any;
|
||||
|
||||
const resourcesPath = `${BASE_URL}${keycloak_resources}/login/resources`;
|
||||
|
||||
export const kcContextCommonMock: KcContext.Common = {
|
||||
"themeVersion": "0.0.0",
|
||||
"keycloakifyVersion": "0.0.0",
|
||||
"themeType": "login",
|
||||
"themeName": "my-theme-name",
|
||||
"url": {
|
||||
"loginAction": "#",
|
||||
themeVersion: "0.0.0",
|
||||
keycloakifyVersion: "0.0.0",
|
||||
themeType: "login",
|
||||
themeName: "my-theme-name",
|
||||
url: {
|
||||
loginAction: "#",
|
||||
resourcesPath,
|
||||
"resourcesCommonPath": `${resourcesPath}/${resources_common}`,
|
||||
"loginRestartFlowUrl": "/auth/realms/myrealm/login-actions/restart?client_id=account&tab_id=HoAx28ja4xg",
|
||||
"loginUrl": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg",
|
||||
"ssoLoginInOtherTabsUrl": "/auth/realms/myrealm/login-actions/switch?client_id=account&tab_id=HoAx28ja4xg"
|
||||
resourcesCommonPath: `${resourcesPath}/${resources_common}`,
|
||||
loginRestartFlowUrl:
|
||||
"/auth/realms/myrealm/login-actions/restart?client_id=account&tab_id=HoAx28ja4xg",
|
||||
loginUrl:
|
||||
"/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg",
|
||||
ssoLoginInOtherTabsUrl:
|
||||
"/auth/realms/myrealm/login-actions/switch?client_id=account&tab_id=HoAx28ja4xg"
|
||||
},
|
||||
"realm": {
|
||||
"name": "myrealm",
|
||||
"displayName": "myrealm",
|
||||
"displayNameHtml": "myrealm",
|
||||
"internationalizationEnabled": true,
|
||||
"registrationEmailAsUsername": false
|
||||
realm: {
|
||||
name: "myrealm",
|
||||
displayName: "myrealm",
|
||||
displayNameHtml: "myrealm",
|
||||
internationalizationEnabled: true,
|
||||
registrationEmailAsUsername: false
|
||||
},
|
||||
"messagesPerField": {
|
||||
"printIfExists": () => {
|
||||
messagesPerField: {
|
||||
printIfExists: () => {
|
||||
return undefined;
|
||||
},
|
||||
"existsError": () => false,
|
||||
"get": fieldName => `Fake error for ${fieldName}`,
|
||||
"exists": () => false,
|
||||
"getFirstError": fieldName => `Fake error for ${fieldName}`
|
||||
existsError: () => false,
|
||||
get: fieldName => `Fake error for ${fieldName}`,
|
||||
exists: () => false,
|
||||
getFirstError: fieldName => `Fake error for ${fieldName}`
|
||||
},
|
||||
"locale": {
|
||||
"supported": [
|
||||
locale: {
|
||||
supported: [
|
||||
/* spell-checker: disable */
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=de",
|
||||
"label": "Deutsch",
|
||||
"languageTag": "de"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=de",
|
||||
label: "Deutsch",
|
||||
languageTag: "de"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=no",
|
||||
"label": "Norsk",
|
||||
"languageTag": "no"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=no",
|
||||
label: "Norsk",
|
||||
languageTag: "no"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=ru",
|
||||
"label": "Русский",
|
||||
"languageTag": "ru"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=ru",
|
||||
label: "Русский",
|
||||
languageTag: "ru"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=sv",
|
||||
"label": "Svenska",
|
||||
"languageTag": "sv"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=sv",
|
||||
label: "Svenska",
|
||||
languageTag: "sv"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=pt-BR",
|
||||
"label": "Português (Brasil)",
|
||||
"languageTag": "pt-BR"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=pt-BR",
|
||||
label: "Português (Brasil)",
|
||||
languageTag: "pt-BR"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=lt",
|
||||
"label": "Lietuvių",
|
||||
"languageTag": "lt"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=lt",
|
||||
label: "Lietuvių",
|
||||
languageTag: "lt"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=en",
|
||||
"label": "English",
|
||||
"languageTag": "en"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=en",
|
||||
label: "English",
|
||||
languageTag: "en"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=it",
|
||||
"label": "Italiano",
|
||||
"languageTag": "it"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=it",
|
||||
label: "Italiano",
|
||||
languageTag: "it"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=fr",
|
||||
"label": "Français",
|
||||
"languageTag": "fr"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=fr",
|
||||
label: "Français",
|
||||
languageTag: "fr"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=zh-CN",
|
||||
"label": "中文简体",
|
||||
"languageTag": "zh-CN"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=zh-CN",
|
||||
label: "中文简体",
|
||||
languageTag: "zh-CN"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=es",
|
||||
"label": "Español",
|
||||
"languageTag": "es"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=es",
|
||||
label: "Español",
|
||||
languageTag: "es"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=cs",
|
||||
"label": "Čeština",
|
||||
"languageTag": "cs"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=cs",
|
||||
label: "Čeština",
|
||||
languageTag: "cs"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=ja",
|
||||
"label": "日本語",
|
||||
"languageTag": "ja"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=ja",
|
||||
label: "日本語",
|
||||
languageTag: "ja"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=sk",
|
||||
"label": "Slovenčina",
|
||||
"languageTag": "sk"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=sk",
|
||||
label: "Slovenčina",
|
||||
languageTag: "sk"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=pl",
|
||||
"label": "Polski",
|
||||
"languageTag": "pl"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=pl",
|
||||
label: "Polski",
|
||||
languageTag: "pl"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=ca",
|
||||
"label": "Català",
|
||||
"languageTag": "ca"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=ca",
|
||||
label: "Català",
|
||||
languageTag: "ca"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=nl",
|
||||
"label": "Nederlands",
|
||||
"languageTag": "nl"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=nl",
|
||||
label: "Nederlands",
|
||||
languageTag: "nl"
|
||||
},
|
||||
{
|
||||
"url": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=tr",
|
||||
"label": "Türkçe",
|
||||
"languageTag": "tr"
|
||||
url: "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg&execution=ee6c2834-46a4-4a20-a1b6-f6d6f6451b36&kc_locale=tr",
|
||||
label: "Türkçe",
|
||||
languageTag: "tr"
|
||||
}
|
||||
/* spell-checker: enable */
|
||||
],
|
||||
"currentLanguageTag": "en"
|
||||
currentLanguageTag: "en"
|
||||
},
|
||||
"auth": {
|
||||
"showUsername": false,
|
||||
"showResetCredentials": false,
|
||||
"showTryAnotherWayLink": false
|
||||
auth: {
|
||||
showUsername: false,
|
||||
showResetCredentials: false,
|
||||
showTryAnotherWayLink: false
|
||||
},
|
||||
"client": {
|
||||
"clientId": "myApp",
|
||||
"attributes": {}
|
||||
client: {
|
||||
clientId: "myApp",
|
||||
attributes: {}
|
||||
},
|
||||
"scripts": [],
|
||||
"isAppInitiatedAction": false,
|
||||
"properties": {}
|
||||
scripts: [],
|
||||
isAppInitiatedAction: false,
|
||||
properties: {}
|
||||
};
|
||||
|
||||
const loginUrl = {
|
||||
...kcContextCommonMock.url,
|
||||
"loginResetCredentialsUrl": "/auth/realms/myrealm/login-actions/reset-credentials?client_id=account&tab_id=HoAx28ja4xg",
|
||||
"registrationUrl": "/auth/realms/myrealm/login-actions/registration?client_id=account&tab_id=HoAx28ja4xg",
|
||||
"oauth2DeviceVerificationAction": "/auth/realms/myrealm/device",
|
||||
"oauthAction": "/auth/realms/myrealm/login-actions/consent?client_id=account&tab_id=HoAx28ja4xg"
|
||||
loginResetCredentialsUrl:
|
||||
"/auth/realms/myrealm/login-actions/reset-credentials?client_id=account&tab_id=HoAx28ja4xg",
|
||||
registrationUrl:
|
||||
"/auth/realms/myrealm/login-actions/registration?client_id=account&tab_id=HoAx28ja4xg",
|
||||
oauth2DeviceVerificationAction: "/auth/realms/myrealm/device",
|
||||
oauthAction:
|
||||
"/auth/realms/myrealm/login-actions/consent?client_id=account&tab_id=HoAx28ja4xg"
|
||||
};
|
||||
|
||||
export const kcContextMocks = [
|
||||
id<KcContext.Login>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login.ftl",
|
||||
"url": loginUrl,
|
||||
"realm": {
|
||||
pageId: "login.ftl",
|
||||
url: loginUrl,
|
||||
realm: {
|
||||
...kcContextCommonMock.realm,
|
||||
"loginWithEmailAllowed": true,
|
||||
"rememberMe": true,
|
||||
"password": true,
|
||||
"resetPasswordAllowed": true,
|
||||
"registrationAllowed": true
|
||||
loginWithEmailAllowed: true,
|
||||
rememberMe: true,
|
||||
password: true,
|
||||
resetPasswordAllowed: true,
|
||||
registrationAllowed: true
|
||||
},
|
||||
"auth": kcContextCommonMock.auth!,
|
||||
"social": {
|
||||
"displayInfo": true
|
||||
auth: kcContextCommonMock.auth!,
|
||||
social: {
|
||||
displayInfo: true
|
||||
},
|
||||
"usernameHidden": false,
|
||||
"login": {},
|
||||
"registrationDisabled": false
|
||||
usernameHidden: false,
|
||||
login: {},
|
||||
registrationDisabled: false
|
||||
}),
|
||||
id<KcContext.Register>({
|
||||
...kcContextCommonMock,
|
||||
"url": {
|
||||
url: {
|
||||
...loginUrl,
|
||||
"registrationAction":
|
||||
registrationAction:
|
||||
"http://localhost:8080/auth/realms/myrealm/login-actions/registration?session_code=gwZdUeO7pbYpFTRxiIxRg_QtzMbtFTKrNu6XW_f8asM&execution=12146ce0-b139-4bbd-b25b-0eccfee6577e&client_id=account&tab_id=uS8lYfebLa0"
|
||||
},
|
||||
"isAppInitiatedAction": false,
|
||||
"passwordRequired": true,
|
||||
"recaptchaRequired": false,
|
||||
"pageId": "register.ftl",
|
||||
"profile": {
|
||||
isAppInitiatedAction: false,
|
||||
passwordRequired: true,
|
||||
recaptchaRequired: false,
|
||||
pageId: "register.ftl",
|
||||
profile: {
|
||||
attributes,
|
||||
attributesByName
|
||||
},
|
||||
"scripts": [
|
||||
scripts: [
|
||||
//"https://www.google.com/recaptcha/api.js"
|
||||
]
|
||||
}),
|
||||
id<KcContext.Info>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "info.ftl",
|
||||
"messageHeader": "<Message header>",
|
||||
"requiredActions": undefined,
|
||||
"skipLink": false,
|
||||
"actionUri": "#",
|
||||
"client": {
|
||||
"clientId": "myApp",
|
||||
"baseUrl": "#",
|
||||
"attributes": {}
|
||||
pageId: "info.ftl",
|
||||
messageHeader: "<Message header>",
|
||||
requiredActions: undefined,
|
||||
skipLink: false,
|
||||
actionUri: "#",
|
||||
client: {
|
||||
clientId: "myApp",
|
||||
baseUrl: "#",
|
||||
attributes: {}
|
||||
}
|
||||
}),
|
||||
id<KcContext.Error>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "error.ftl",
|
||||
"client": {
|
||||
"clientId": "myApp",
|
||||
"baseUrl": "#",
|
||||
"attributes": {}
|
||||
pageId: "error.ftl",
|
||||
client: {
|
||||
clientId: "myApp",
|
||||
baseUrl: "#",
|
||||
attributes: {}
|
||||
},
|
||||
"message": {
|
||||
"type": "error",
|
||||
"summary": "This is the error message"
|
||||
message: {
|
||||
type: "error",
|
||||
summary: "This is the error message"
|
||||
}
|
||||
}),
|
||||
id<KcContext.LoginResetPassword>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-reset-password.ftl",
|
||||
"realm": {
|
||||
pageId: "login-reset-password.ftl",
|
||||
realm: {
|
||||
...kcContextCommonMock.realm,
|
||||
"loginWithEmailAllowed": false,
|
||||
"duplicateEmailsAllowed": false
|
||||
loginWithEmailAllowed: false,
|
||||
duplicateEmailsAllowed: false
|
||||
},
|
||||
"url": loginUrl,
|
||||
"auth": {}
|
||||
url: loginUrl,
|
||||
auth: {}
|
||||
}),
|
||||
id<KcContext.LoginVerifyEmail>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-verify-email.ftl",
|
||||
"user": {
|
||||
"email": "john.doe@gmail.com"
|
||||
pageId: "login-verify-email.ftl",
|
||||
user: {
|
||||
email: "john.doe@gmail.com"
|
||||
}
|
||||
}),
|
||||
id<KcContext.Terms>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "terms.ftl"
|
||||
pageId: "terms.ftl"
|
||||
}),
|
||||
id<KcContext.LoginDeviceVerifyUserCode>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-oauth2-device-verify-user-code.ftl",
|
||||
pageId: "login-oauth2-device-verify-user-code.ftl",
|
||||
url: loginUrl
|
||||
}),
|
||||
id<KcContext.LoginOauthGrant>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-oauth-grant.ftl",
|
||||
pageId: "login-oauth-grant.ftl",
|
||||
oauth: {
|
||||
code: "5-1N4CIzfi1aprIQjmylI-9e3spLCWW9i5d-GDcs-Sw",
|
||||
clientScopesRequested: [
|
||||
@ -332,150 +344,152 @@ export const kcContextMocks = [
|
||||
}),
|
||||
id<KcContext.LoginOtp>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-otp.ftl",
|
||||
"otpLogin": {
|
||||
"userOtpCredentials": [
|
||||
pageId: "login-otp.ftl",
|
||||
otpLogin: {
|
||||
userOtpCredentials: [
|
||||
{
|
||||
"id": "id1",
|
||||
"userLabel": "label1"
|
||||
id: "id1",
|
||||
userLabel: "label1"
|
||||
},
|
||||
{
|
||||
"id": "id2",
|
||||
"userLabel": "label2"
|
||||
id: "id2",
|
||||
userLabel: "label2"
|
||||
}
|
||||
]
|
||||
}
|
||||
}),
|
||||
id<KcContext.LoginUsername>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-username.ftl",
|
||||
"url": loginUrl,
|
||||
"realm": {
|
||||
pageId: "login-username.ftl",
|
||||
url: loginUrl,
|
||||
realm: {
|
||||
...kcContextCommonMock.realm,
|
||||
"loginWithEmailAllowed": true,
|
||||
"rememberMe": true,
|
||||
"password": true,
|
||||
"resetPasswordAllowed": true,
|
||||
"registrationAllowed": true
|
||||
loginWithEmailAllowed: true,
|
||||
rememberMe: true,
|
||||
password: true,
|
||||
resetPasswordAllowed: true,
|
||||
registrationAllowed: true
|
||||
},
|
||||
"social": {
|
||||
"displayInfo": true
|
||||
social: {
|
||||
displayInfo: true
|
||||
},
|
||||
"usernameHidden": false,
|
||||
"login": {},
|
||||
"registrationDisabled": false
|
||||
usernameHidden: false,
|
||||
login: {},
|
||||
registrationDisabled: false
|
||||
}),
|
||||
id<KcContext.LoginPassword>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-password.ftl",
|
||||
"url": loginUrl,
|
||||
"realm": {
|
||||
pageId: "login-password.ftl",
|
||||
url: loginUrl,
|
||||
realm: {
|
||||
...kcContextCommonMock.realm,
|
||||
"resetPasswordAllowed": true
|
||||
resetPasswordAllowed: true
|
||||
},
|
||||
"social": {
|
||||
"displayInfo": false
|
||||
social: {
|
||||
displayInfo: false
|
||||
}
|
||||
}),
|
||||
id<KcContext.WebauthnAuthenticate>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "webauthn-authenticate.ftl",
|
||||
"url": loginUrl,
|
||||
"authenticators": {
|
||||
"authenticators": []
|
||||
pageId: "webauthn-authenticate.ftl",
|
||||
url: loginUrl,
|
||||
authenticators: {
|
||||
authenticators: []
|
||||
},
|
||||
"realm": {
|
||||
realm: {
|
||||
...kcContextCommonMock.realm,
|
||||
"password": true,
|
||||
"registrationAllowed": true
|
||||
password: true,
|
||||
registrationAllowed: true
|
||||
},
|
||||
"challenge": "",
|
||||
"userVerification": "not specified",
|
||||
"rpId": "",
|
||||
"createTimeout": "0",
|
||||
"isUserIdentified": "false",
|
||||
"shouldDisplayAuthenticators": false,
|
||||
"social": {
|
||||
"displayInfo": false
|
||||
challenge: "",
|
||||
userVerification: "not specified",
|
||||
rpId: "",
|
||||
createTimeout: "0",
|
||||
isUserIdentified: "false",
|
||||
shouldDisplayAuthenticators: false,
|
||||
social: {
|
||||
displayInfo: false
|
||||
},
|
||||
"login": {}
|
||||
login: {}
|
||||
}),
|
||||
id<KcContext.LoginUpdatePassword>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-update-password.ftl"
|
||||
pageId: "login-update-password.ftl"
|
||||
}),
|
||||
id<KcContext.LoginUpdateProfile>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-update-profile.ftl",
|
||||
"profile": {
|
||||
pageId: "login-update-profile.ftl",
|
||||
profile: {
|
||||
attributes,
|
||||
attributesByName
|
||||
}
|
||||
}),
|
||||
id<KcContext.LoginIdpLinkConfirm>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-idp-link-confirm.ftl",
|
||||
"idpAlias": "FranceConnect"
|
||||
pageId: "login-idp-link-confirm.ftl",
|
||||
idpAlias: "FranceConnect"
|
||||
}),
|
||||
id<KcContext.LoginIdpLinkEmail>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-idp-link-email.ftl",
|
||||
"idpAlias": "FranceConnect",
|
||||
"brokerContext": {
|
||||
"username": "anUsername"
|
||||
pageId: "login-idp-link-email.ftl",
|
||||
idpAlias: "FranceConnect",
|
||||
brokerContext: {
|
||||
username: "anUsername"
|
||||
}
|
||||
}),
|
||||
id<KcContext.LoginConfigTotp>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "login-config-totp.ftl",
|
||||
"totp": {
|
||||
"totpSecretEncoded": "KVVF G2BY N4YX S6LB IUYT K2LH IFYE 4SBV",
|
||||
"qrUrl": "#",
|
||||
"totpSecretQrCode":
|
||||
pageId: "login-config-totp.ftl",
|
||||
totp: {
|
||||
totpSecretEncoded: "KVVF G2BY N4YX S6LB IUYT K2LH IFYE 4SBV",
|
||||
qrUrl: "#",
|
||||
totpSecretQrCode:
|
||||
"iVBORw0KGgoAAAANSUhEUgAAAPYAAAD2AQAAAADNaUdlAAACM0lEQVR4Xu3OIZJgOQwDUDFd2UxiurLAVnnbHw4YGDKtSiWOn4Gxf81//7r/+q8b4HfLGBZDK9d85NmNR+sB42sXvOYrN5P1DcgYYFTGfOlbzE8gzwy3euweGizw7cfdl34/GRhlkxjKNV+5AebPXPORX1JuB9x8ZfbyyD2y1krWAKsbMq1HnqQDaLfa77p4+MqvzEGSqvSAD/2IHW2yHaigR9tX3m8dDIYGcNf3f+gDpVBZbZU77zyJ6Rlcy+qoTMG887KAPD9hsh6a1Sv3gJUHGHUAxSMzj7zqDDe7Phmt2eG+8UsMxjRGm816MAO+8VMl1R1jGHOrZB/5Zo/WXAPgxixm9Mo96vDGrM1eOto8c4Ax4wF437mifOXlpiPzCnN7Y9l95NnEMxgMY9AAGA8fucH14Y1aVb6N/cqrmyh0BVht7k1e+bU8LK0Cg5vmVq9c5vHIjOfqxDIfeTraNVTwewa4wVe+SW5N+uP1qACeudUZbqGOfA6VZV750Noq2Xx3kpveV44ZelSV1V7KFHzkWyVrrlUwG0Pl9pWnoy3vsQoME6vKI69i5osVgwWzHT7zjmJtMcNUSVn1oYMd7ZodbgowZl45VG0uVuLPUr1yc79uaQBag/mqR34xhlWyHm1prplHboCWdZ4TeZjsK8+dI+jbz1C5hl65mcpgB5dhcj8+dGO+0Ko68+lD37JDD83dpDLzzK+TrQyaVwGj6pUboGV+7+AyN8An/pf84/7rv/4/1l4OCc/1BYMAAAAASUVORK5CYII=",
|
||||
"manualUrl": "#",
|
||||
"totpSecret": "G4nsI8lQagRMUchH8jEG",
|
||||
"otpCredentials": [],
|
||||
"supportedApplications": ["FreeOTP", "Google Authenticator"],
|
||||
"policy": {
|
||||
"algorithm": "HmacSHA1",
|
||||
"digits": 6,
|
||||
"lookAheadWindow": 1,
|
||||
"type": "totp",
|
||||
"period": 30,
|
||||
"getAlgorithmKey": () => "SHA1"
|
||||
manualUrl: "#",
|
||||
totpSecret: "G4nsI8lQagRMUchH8jEG",
|
||||
otpCredentials: [],
|
||||
supportedApplications: ["FreeOTP", "Google Authenticator"],
|
||||
policy: {
|
||||
algorithm: "HmacSHA1",
|
||||
digits: 6,
|
||||
lookAheadWindow: 1,
|
||||
type: "totp",
|
||||
period: 30,
|
||||
getAlgorithmKey: () => "SHA1"
|
||||
}
|
||||
}
|
||||
}),
|
||||
id<KcContext.LogoutConfirm>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "logout-confirm.ftl",
|
||||
"url": {
|
||||
pageId: "logout-confirm.ftl",
|
||||
url: {
|
||||
...kcContextCommonMock.url,
|
||||
"logoutConfirmAction": "Continuer?"
|
||||
logoutConfirmAction: "Continuer?"
|
||||
},
|
||||
"client": {
|
||||
"clientId": "myApp",
|
||||
"baseUrl": "#",
|
||||
"attributes": {}
|
||||
client: {
|
||||
clientId: "myApp",
|
||||
baseUrl: "#",
|
||||
attributes: {}
|
||||
},
|
||||
"logoutConfirm": { "code": "123", skipLink: false }
|
||||
logoutConfirm: { code: "123", skipLink: false }
|
||||
}),
|
||||
id<KcContext.IdpReviewUserProfile>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "idp-review-user-profile.ftl",
|
||||
"profile": {
|
||||
pageId: "idp-review-user-profile.ftl",
|
||||
profile: {
|
||||
attributes,
|
||||
attributesByName
|
||||
}
|
||||
}),
|
||||
id<KcContext.UpdateEmail>({
|
||||
...kcContextCommonMock,
|
||||
"pageId": "update-email.ftl",
|
||||
"profile": {
|
||||
"attributes": attributes.filter(attribute => attribute.name === "email"),
|
||||
"attributesByName": Object.fromEntries(
|
||||
attributes.filter(attribute => attribute.name === "email").map(attribute => [attribute.name, attribute])
|
||||
pageId: "update-email.ftl",
|
||||
profile: {
|
||||
attributes: attributes.filter(attribute => attribute.name === "email"),
|
||||
attributesByName: Object.fromEntries(
|
||||
attributes
|
||||
.filter(attribute => attribute.name === "email")
|
||||
.map(attribute => [attribute.name, attribute])
|
||||
)
|
||||
}
|
||||
}),
|
||||
@ -502,8 +516,8 @@ export const kcContextMocks = [
|
||||
id<KcContext.SamlPostForm>({
|
||||
...kcContextCommonMock,
|
||||
pageId: "saml-post-form.ftl",
|
||||
"samlPost": {
|
||||
"url": ""
|
||||
samlPost: {
|
||||
url: ""
|
||||
}
|
||||
}),
|
||||
id<KcContext.LoginPageExpired>({
|
||||
@ -514,107 +528,107 @@ export const kcContextMocks = [
|
||||
id<KcContext.FrontchannelLogout>({
|
||||
...kcContextCommonMock,
|
||||
pageId: "frontchannel-logout.ftl",
|
||||
"logout": {
|
||||
"clients": [
|
||||
logout: {
|
||||
clients: [
|
||||
{
|
||||
"name": "myApp",
|
||||
"frontChannelLogoutUrl": "#"
|
||||
name: "myApp",
|
||||
frontChannelLogoutUrl: "#"
|
||||
},
|
||||
{
|
||||
"name": "myApp2",
|
||||
"frontChannelLogoutUrl": "#"
|
||||
name: "myApp2",
|
||||
frontChannelLogoutUrl: "#"
|
||||
}
|
||||
]
|
||||
}
|
||||
}),
|
||||
id<KcContext.WebauthnRegister>({
|
||||
"pageId": "webauthn-register.ftl",
|
||||
pageId: "webauthn-register.ftl",
|
||||
...kcContextCommonMock,
|
||||
"challenge": "random-challenge-string",
|
||||
"userid": "user123",
|
||||
"username": "johndoe",
|
||||
"signatureAlgorithms": ["ES256", "RS256"],
|
||||
"rpEntityName": "Example Corp",
|
||||
"rpId": "example.com",
|
||||
"attestationConveyancePreference": "direct",
|
||||
"authenticatorAttachment": "platform",
|
||||
"requireResidentKey": "required",
|
||||
"userVerificationRequirement": "preferred",
|
||||
"createTimeout": 60000,
|
||||
"excludeCredentialIds": "credId123,credId456",
|
||||
"isSetRetry": false,
|
||||
"isAppInitiatedAction": true
|
||||
challenge: "random-challenge-string",
|
||||
userid: "user123",
|
||||
username: "johndoe",
|
||||
signatureAlgorithms: ["ES256", "RS256"],
|
||||
rpEntityName: "Example Corp",
|
||||
rpId: "example.com",
|
||||
attestationConveyancePreference: "direct",
|
||||
authenticatorAttachment: "platform",
|
||||
requireResidentKey: "required",
|
||||
userVerificationRequirement: "preferred",
|
||||
createTimeout: 60000,
|
||||
excludeCredentialIds: "credId123,credId456",
|
||||
isSetRetry: false,
|
||||
isAppInitiatedAction: true
|
||||
}),
|
||||
id<KcContext.DeleteCredential>({
|
||||
"pageId": "delete-credential.ftl",
|
||||
pageId: "delete-credential.ftl",
|
||||
...kcContextCommonMock,
|
||||
"credentialLabel": "myCredential"
|
||||
credentialLabel: "myCredential"
|
||||
}),
|
||||
id<KcContext.Code>({
|
||||
"pageId": "code.ftl",
|
||||
pageId: "code.ftl",
|
||||
...kcContextCommonMock,
|
||||
"code": {
|
||||
"success": true,
|
||||
"code": "123456"
|
||||
code: {
|
||||
success: true,
|
||||
code: "123456"
|
||||
}
|
||||
}),
|
||||
id<KcContext.DeleteAccountConfirm>({
|
||||
"pageId": "delete-account-confirm.ftl",
|
||||
pageId: "delete-account-confirm.ftl",
|
||||
...kcContextCommonMock,
|
||||
"triggered_from_aia": true
|
||||
triggered_from_aia: true
|
||||
}),
|
||||
id<KcContext.LoginRecoveryAuthnCodeConfig>({
|
||||
"pageId": "login-recovery-authn-code-config.ftl",
|
||||
pageId: "login-recovery-authn-code-config.ftl",
|
||||
...kcContextCommonMock,
|
||||
"recoveryAuthnCodesConfigBean": {
|
||||
"generatedRecoveryAuthnCodesList": ["code123", "code456", "code789"],
|
||||
"generatedRecoveryAuthnCodesAsString": "code123, code456, code789",
|
||||
"generatedAt": new Date().getTime()
|
||||
recoveryAuthnCodesConfigBean: {
|
||||
generatedRecoveryAuthnCodesList: ["code123", "code456", "code789"],
|
||||
generatedRecoveryAuthnCodesAsString: "code123, code456, code789",
|
||||
generatedAt: new Date().getTime()
|
||||
}
|
||||
}),
|
||||
id<KcContext.LoginRecoveryAuthnCodeInput>({
|
||||
"pageId": "login-recovery-authn-code-input.ftl",
|
||||
pageId: "login-recovery-authn-code-input.ftl",
|
||||
...kcContextCommonMock,
|
||||
"recoveryAuthnCodesInputBean": {
|
||||
"codeNumber": 1234
|
||||
recoveryAuthnCodesInputBean: {
|
||||
codeNumber: 1234
|
||||
}
|
||||
}),
|
||||
id<KcContext.LoginResetOtp>({
|
||||
"pageId": "login-reset-otp.ftl",
|
||||
pageId: "login-reset-otp.ftl",
|
||||
...kcContextCommonMock,
|
||||
"configuredOtpCredentials": {
|
||||
"userOtpCredentials": [
|
||||
configuredOtpCredentials: {
|
||||
userOtpCredentials: [
|
||||
{
|
||||
"id": "otpId1",
|
||||
"userLabel": "OTP Device 1"
|
||||
id: "otpId1",
|
||||
userLabel: "OTP Device 1"
|
||||
},
|
||||
{
|
||||
"id": "otpId2",
|
||||
"userLabel": "OTP Device 2"
|
||||
id: "otpId2",
|
||||
userLabel: "OTP Device 2"
|
||||
},
|
||||
{
|
||||
"id": "otpId3",
|
||||
"userLabel": "Backup OTP"
|
||||
id: "otpId3",
|
||||
userLabel: "Backup OTP"
|
||||
}
|
||||
],
|
||||
"selectedCredentialId": "otpId2"
|
||||
selectedCredentialId: "otpId2"
|
||||
}
|
||||
}),
|
||||
id<KcContext.LoginX509Info>({
|
||||
"pageId": "login-x509-info.ftl",
|
||||
pageId: "login-x509-info.ftl",
|
||||
...kcContextCommonMock,
|
||||
"x509": {
|
||||
"formData": {
|
||||
"subjectDN": "CN=John Doe, O=Example Corp, C=US",
|
||||
"isUserEnabled": true,
|
||||
"username": "johndoe"
|
||||
x509: {
|
||||
formData: {
|
||||
subjectDN: "CN=John Doe, O=Example Corp, C=US",
|
||||
isUserEnabled: true,
|
||||
username: "johndoe"
|
||||
}
|
||||
}
|
||||
}),
|
||||
id<KcContext.WebauthnError>({
|
||||
"pageId": "webauthn-error.ftl",
|
||||
pageId: "webauthn-error.ftl",
|
||||
...kcContextCommonMock,
|
||||
"isAppInitiatedAction": true
|
||||
isAppInitiatedAction: true
|
||||
})
|
||||
];
|
||||
|
||||
|
@ -33,7 +33,9 @@ export function useDownloadTerms(params: {
|
||||
const downloadTermMarkdownConst = useConstCallback(downloadTermMarkdown);
|
||||
|
||||
const downloadTermMarkdownMemoized = useConst(() =>
|
||||
memoize((currentLanguageTag: string) => downloadTermMarkdownConst({ currentLanguageTag }))
|
||||
memoize((currentLanguageTag: string) =>
|
||||
downloadTermMarkdownConst({ currentLanguageTag })
|
||||
)
|
||||
);
|
||||
|
||||
return { downloadTermMarkdownMemoized };
|
||||
@ -41,9 +43,9 @@ export function useDownloadTerms(params: {
|
||||
|
||||
useEffect(() => {
|
||||
if (kcContext.pageId === "terms.ftl" || kcContext.termsAcceptanceRequired) {
|
||||
downloadTermMarkdownMemoized(kcContext.locale?.currentLanguageTag ?? fallbackLanguageTag).then(
|
||||
thermMarkdown => (evtTermsMarkdown.state = thermMarkdown)
|
||||
);
|
||||
downloadTermMarkdownMemoized(
|
||||
kcContext.locale?.currentLanguageTag ?? fallbackLanguageTag
|
||||
).then(thermMarkdown => (evtTermsMarkdown.state = thermMarkdown));
|
||||
}
|
||||
}, []);
|
||||
}
|
||||
|
@ -2,131 +2,138 @@ import { createUseClassName } from "keycloakify/lib/useGetClassName";
|
||||
import type { ClassKey } from "keycloakify/login/TemplateProps";
|
||||
|
||||
export const { useGetClassName } = createUseClassName<ClassKey>({
|
||||
"defaultClasses": {
|
||||
"kcBodyClass": undefined,
|
||||
"kcHeaderWrapperClass": undefined,
|
||||
"kcLocaleWrapperClass": undefined,
|
||||
"kcInfoAreaWrapperClass": undefined,
|
||||
"kcFormButtonsWrapperClass": undefined,
|
||||
"kcFormOptionsWrapperClass": undefined,
|
||||
"kcLocaleDropDownClass": undefined,
|
||||
"kcLocaleListItemClass": undefined,
|
||||
"kcContentWrapperClass": undefined,
|
||||
"kcCheckboxInputClass": undefined,
|
||||
defaultClasses: {
|
||||
kcBodyClass: undefined,
|
||||
kcHeaderWrapperClass: undefined,
|
||||
kcLocaleWrapperClass: undefined,
|
||||
kcInfoAreaWrapperClass: undefined,
|
||||
kcFormButtonsWrapperClass: undefined,
|
||||
kcFormOptionsWrapperClass: undefined,
|
||||
kcLocaleDropDownClass: undefined,
|
||||
kcLocaleListItemClass: undefined,
|
||||
kcContentWrapperClass: undefined,
|
||||
kcCheckboxInputClass: undefined,
|
||||
|
||||
"kcLogoIdP-facebook": "fa fa-facebook",
|
||||
"kcAuthenticatorOTPClass": "fa fa-mobile list-view-pf-icon-lg",
|
||||
kcAuthenticatorOTPClass: "fa fa-mobile list-view-pf-icon-lg",
|
||||
"kcLogoIdP-bitbucket": "fa fa-bitbucket",
|
||||
"kcAuthenticatorWebAuthnClass": "fa fa-key list-view-pf-icon-lg",
|
||||
"kcWebAuthnDefaultIcon": "pficon pficon-key",
|
||||
kcAuthenticatorWebAuthnClass: "fa fa-key list-view-pf-icon-lg",
|
||||
kcWebAuthnDefaultIcon: "pficon pficon-key",
|
||||
"kcLogoIdP-stackoverflow": "fa fa-stack-overflow",
|
||||
"kcSelectAuthListItemClass": "pf-l-stack__item select-auth-box-parent pf-l-split",
|
||||
kcSelectAuthListItemClass: "pf-l-stack__item select-auth-box-parent pf-l-split",
|
||||
"kcLogoIdP-microsoft": "fa fa-windows",
|
||||
"kcLoginOTPListItemHeaderClass": "pf-c-tile__header",
|
||||
"kcLocaleItemClass": "pf-c-dropdown__menu-item",
|
||||
"kcLoginOTPListItemIconBodyClass": "pf-c-tile__icon",
|
||||
"kcInputHelperTextAfterClass": "pf-c-form__helper-text pf-c-form__helper-text-after",
|
||||
"kcFormClass": "form-horizontal",
|
||||
"kcSelectAuthListClass": "pf-l-stack select-auth-container",
|
||||
"kcInputClassRadioCheckboxLabelDisabled": "pf-m-disabled",
|
||||
"kcSelectAuthListItemIconClass": "pf-l-split__item select-auth-box-icon",
|
||||
"kcRecoveryCodesWarning": "kc-recovery-codes-warning",
|
||||
"kcFormSettingClass": "login-pf-settings",
|
||||
"kcWebAuthnBLE": "fa fa-bluetooth-b",
|
||||
"kcInputWrapperClass": "col-xs-12 col-sm-12 col-md-12 col-lg-12",
|
||||
"kcSelectAuthListItemArrowIconClass": "fa fa-angle-right fa-lg",
|
||||
"kcFeedbackAreaClass": "col-md-12",
|
||||
"kcFormPasswordVisibilityButtonClass": "pf-c-button pf-m-control",
|
||||
kcLoginOTPListItemHeaderClass: "pf-c-tile__header",
|
||||
kcLocaleItemClass: "pf-c-dropdown__menu-item",
|
||||
kcLoginOTPListItemIconBodyClass: "pf-c-tile__icon",
|
||||
kcInputHelperTextAfterClass:
|
||||
"pf-c-form__helper-text pf-c-form__helper-text-after",
|
||||
kcFormClass: "form-horizontal",
|
||||
kcSelectAuthListClass: "pf-l-stack select-auth-container",
|
||||
kcInputClassRadioCheckboxLabelDisabled: "pf-m-disabled",
|
||||
kcSelectAuthListItemIconClass: "pf-l-split__item select-auth-box-icon",
|
||||
kcRecoveryCodesWarning: "kc-recovery-codes-warning",
|
||||
kcFormSettingClass: "login-pf-settings",
|
||||
kcWebAuthnBLE: "fa fa-bluetooth-b",
|
||||
kcInputWrapperClass: "col-xs-12 col-sm-12 col-md-12 col-lg-12",
|
||||
kcSelectAuthListItemArrowIconClass: "fa fa-angle-right fa-lg",
|
||||
kcFeedbackAreaClass: "col-md-12",
|
||||
kcFormPasswordVisibilityButtonClass: "pf-c-button pf-m-control",
|
||||
"kcLogoIdP-google": "fa fa-google",
|
||||
"kcCheckLabelClass": "pf-c-check__label",
|
||||
"kcSelectAuthListItemFillClass": "pf-l-split__item pf-m-fill",
|
||||
"kcAuthenticatorDefaultClass": "fa fa-list list-view-pf-icon-lg",
|
||||
kcCheckLabelClass: "pf-c-check__label",
|
||||
kcSelectAuthListItemFillClass: "pf-l-split__item pf-m-fill",
|
||||
kcAuthenticatorDefaultClass: "fa fa-list list-view-pf-icon-lg",
|
||||
"kcLogoIdP-gitlab": "fa fa-gitlab",
|
||||
"kcFormAreaClass": "col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-8 col-lg-offset-2",
|
||||
"kcFormButtonsClass": "col-xs-12 col-sm-12 col-md-12 col-lg-12",
|
||||
"kcInputClassRadioLabel": "pf-c-radio__label",
|
||||
"kcAuthenticatorWebAuthnPasswordlessClass": "fa fa-key list-view-pf-icon-lg",
|
||||
"kcSelectAuthListItemHeadingClass": "pf-l-stack__item select-auth-box-headline pf-c-title",
|
||||
"kcInfoAreaClass": "col-xs-12 col-sm-4 col-md-4 col-lg-5 details",
|
||||
"kcLogoLink": "http://www.keycloak.org",
|
||||
"kcContainerClass": "container-fluid",
|
||||
"kcSelectAuthListItemTitle": "select-auth-box-paragraph",
|
||||
"kcHtmlClass": "login-pf",
|
||||
"kcLoginOTPListItemTitleClass": "pf-c-tile__title",
|
||||
kcFormAreaClass:
|
||||
"col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-8 col-lg-offset-2",
|
||||
kcFormButtonsClass: "col-xs-12 col-sm-12 col-md-12 col-lg-12",
|
||||
kcInputClassRadioLabel: "pf-c-radio__label",
|
||||
kcAuthenticatorWebAuthnPasswordlessClass: "fa fa-key list-view-pf-icon-lg",
|
||||
kcSelectAuthListItemHeadingClass:
|
||||
"pf-l-stack__item select-auth-box-headline pf-c-title",
|
||||
kcInfoAreaClass: "col-xs-12 col-sm-4 col-md-4 col-lg-5 details",
|
||||
kcLogoLink: "http://www.keycloak.org",
|
||||
kcContainerClass: "container-fluid",
|
||||
kcSelectAuthListItemTitle: "select-auth-box-paragraph",
|
||||
kcHtmlClass: "login-pf",
|
||||
kcLoginOTPListItemTitleClass: "pf-c-tile__title",
|
||||
"kcLogoIdP-openshift-v4": "pf-icon pf-icon-openshift",
|
||||
"kcWebAuthnUnknownIcon": "pficon pficon-key unknown-transport-class",
|
||||
"kcFormSocialAccountNameClass": "kc-social-provider-name",
|
||||
kcWebAuthnUnknownIcon: "pficon pficon-key unknown-transport-class",
|
||||
kcFormSocialAccountNameClass: "kc-social-provider-name",
|
||||
"kcLogoIdP-openshift-v3": "pf-icon pf-icon-openshift",
|
||||
"kcLoginOTPListInputClass": "pf-c-tile__input",
|
||||
"kcWebAuthnUSB": "fa fa-usb",
|
||||
"kcInputClassRadio": "pf-c-radio",
|
||||
"kcWebAuthnKeyIcon": "pficon pficon-key",
|
||||
"kcFeedbackInfoIcon": "fa fa-fw fa-info-circle",
|
||||
"kcCommonLogoIdP": "kc-social-provider-logo kc-social-gray",
|
||||
"kcRecoveryCodesActions": "kc-recovery-codes-actions",
|
||||
"kcFormGroupHeader": "pf-c-form__group",
|
||||
"kcFormSocialAccountSectionClass": "kc-social-section kc-social-gray",
|
||||
kcLoginOTPListInputClass: "pf-c-tile__input",
|
||||
kcWebAuthnUSB: "fa fa-usb",
|
||||
kcInputClassRadio: "pf-c-radio",
|
||||
kcWebAuthnKeyIcon: "pficon pficon-key",
|
||||
kcFeedbackInfoIcon: "fa fa-fw fa-info-circle",
|
||||
kcCommonLogoIdP: "kc-social-provider-logo kc-social-gray",
|
||||
kcRecoveryCodesActions: "kc-recovery-codes-actions",
|
||||
kcFormGroupHeader: "pf-c-form__group",
|
||||
kcFormSocialAccountSectionClass: "kc-social-section kc-social-gray",
|
||||
"kcLogoIdP-instagram": "fa fa-instagram",
|
||||
"kcAlertClass": "pf-c-alert pf-m-inline",
|
||||
"kcHeaderClass": "login-pf-page-header",
|
||||
"kcLabelWrapperClass": "col-xs-12 col-sm-12 col-md-12 col-lg-12",
|
||||
"kcFormPasswordVisibilityIconShow": "fa fa-eye",
|
||||
"kcFormSocialAccountLinkClass": "pf-c-login__main-footer-links-item-link",
|
||||
"kcLocaleMainClass": "pf-c-dropdown",
|
||||
"kcInputGroup": "pf-c-input-group",
|
||||
"kcTextareaClass": "form-control",
|
||||
"kcButtonBlockClass": "pf-m-block",
|
||||
"kcButtonClass": "pf-c-button",
|
||||
"kcWebAuthnNFC": "fa fa-wifi",
|
||||
"kcLocaleClass": "col-xs-12 col-sm-1",
|
||||
"kcInputClassCheckboxInput": "pf-c-check__input",
|
||||
"kcFeedbackErrorIcon": "fa fa-fw fa-exclamation-circle",
|
||||
"kcInputLargeClass": "input-lg",
|
||||
"kcInputErrorMessageClass": "pf-c-form__helper-text pf-m-error required kc-feedback-text",
|
||||
"kcRecoveryCodesList": "kc-recovery-codes-list",
|
||||
"kcFormSocialAccountListClass": "pf-c-login__main-footer-links kc-social-links",
|
||||
"kcAlertTitleClass": "pf-c-alert__title kc-feedback-text",
|
||||
"kcAuthenticatorPasswordClass": "fa fa-unlock list-view-pf-icon-lg",
|
||||
"kcCheckInputClass": "pf-c-check__input",
|
||||
kcAlertClass: "pf-c-alert pf-m-inline",
|
||||
kcHeaderClass: "login-pf-page-header",
|
||||
kcLabelWrapperClass: "col-xs-12 col-sm-12 col-md-12 col-lg-12",
|
||||
kcFormPasswordVisibilityIconShow: "fa fa-eye",
|
||||
kcFormSocialAccountLinkClass: "pf-c-login__main-footer-links-item-link",
|
||||
kcLocaleMainClass: "pf-c-dropdown",
|
||||
kcInputGroup: "pf-c-input-group",
|
||||
kcTextareaClass: "form-control",
|
||||
kcButtonBlockClass: "pf-m-block",
|
||||
kcButtonClass: "pf-c-button",
|
||||
kcWebAuthnNFC: "fa fa-wifi",
|
||||
kcLocaleClass: "col-xs-12 col-sm-1",
|
||||
kcInputClassCheckboxInput: "pf-c-check__input",
|
||||
kcFeedbackErrorIcon: "fa fa-fw fa-exclamation-circle",
|
||||
kcInputLargeClass: "input-lg",
|
||||
kcInputErrorMessageClass:
|
||||
"pf-c-form__helper-text pf-m-error required kc-feedback-text",
|
||||
kcRecoveryCodesList: "kc-recovery-codes-list",
|
||||
kcFormSocialAccountListClass: "pf-c-login__main-footer-links kc-social-links",
|
||||
kcAlertTitleClass: "pf-c-alert__title kc-feedback-text",
|
||||
kcAuthenticatorPasswordClass: "fa fa-unlock list-view-pf-icon-lg",
|
||||
kcCheckInputClass: "pf-c-check__input",
|
||||
"kcLogoIdP-linkedin": "fa fa-linkedin",
|
||||
"kcLogoIdP-twitter": "fa fa-twitter",
|
||||
"kcFeedbackWarningIcon": "fa fa-fw fa-exclamation-triangle",
|
||||
"kcResetFlowIcon": "pficon pficon-arrow fa",
|
||||
"kcSelectAuthListItemIconPropertyClass": "fa-2x select-auth-box-icon-properties",
|
||||
"kcFeedbackSuccessIcon": "fa fa-fw fa-check-circle",
|
||||
"kcLoginOTPListClass": "pf-c-tile",
|
||||
"kcSrOnlyClass": "sr-only",
|
||||
"kcFormSocialAccountListGridClass": "pf-l-grid kc-social-grid",
|
||||
"kcButtonDefaultClass": "btn-default",
|
||||
"kcFormGroupErrorClass": "has-error",
|
||||
"kcSelectAuthListItemDescriptionClass": "pf-l-stack__item select-auth-box-desc",
|
||||
"kcSelectAuthListItemBodyClass": "pf-l-split__item pf-l-stack",
|
||||
"kcWebAuthnInternal": "pficon pficon-key",
|
||||
"kcSelectAuthListItemArrowClass": "pf-l-split__item select-auth-box-arrow",
|
||||
"kcCheckClass": "pf-c-check",
|
||||
"kcContentClass": "col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3 col-lg-6 col-lg-offset-3",
|
||||
"kcLogoClass": "login-pf-brand",
|
||||
"kcLoginOTPListItemIconClass": "fa fa-mobile",
|
||||
"kcLoginClass": "login-pf-page",
|
||||
"kcSignUpClass": "login-pf-signup",
|
||||
"kcButtonLargeClass": "btn-lg",
|
||||
"kcFormCardClass": "card-pf",
|
||||
"kcLocaleListClass": "pf-c-dropdown__menu pf-m-align-right",
|
||||
"kcInputClass": "pf-c-form-control",
|
||||
"kcFormGroupClass": "form-group",
|
||||
kcFeedbackWarningIcon: "fa fa-fw fa-exclamation-triangle",
|
||||
kcResetFlowIcon: "pficon pficon-arrow fa",
|
||||
kcSelectAuthListItemIconPropertyClass: "fa-2x select-auth-box-icon-properties",
|
||||
kcFeedbackSuccessIcon: "fa fa-fw fa-check-circle",
|
||||
kcLoginOTPListClass: "pf-c-tile",
|
||||
kcSrOnlyClass: "sr-only",
|
||||
kcFormSocialAccountListGridClass: "pf-l-grid kc-social-grid",
|
||||
kcButtonDefaultClass: "btn-default",
|
||||
kcFormGroupErrorClass: "has-error",
|
||||
kcSelectAuthListItemDescriptionClass: "pf-l-stack__item select-auth-box-desc",
|
||||
kcSelectAuthListItemBodyClass: "pf-l-split__item pf-l-stack",
|
||||
kcWebAuthnInternal: "pficon pficon-key",
|
||||
kcSelectAuthListItemArrowClass: "pf-l-split__item select-auth-box-arrow",
|
||||
kcCheckClass: "pf-c-check",
|
||||
kcContentClass:
|
||||
"col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3 col-lg-6 col-lg-offset-3",
|
||||
kcLogoClass: "login-pf-brand",
|
||||
kcLoginOTPListItemIconClass: "fa fa-mobile",
|
||||
kcLoginClass: "login-pf-page",
|
||||
kcSignUpClass: "login-pf-signup",
|
||||
kcButtonLargeClass: "btn-lg",
|
||||
kcFormCardClass: "card-pf",
|
||||
kcLocaleListClass: "pf-c-dropdown__menu pf-m-align-right",
|
||||
kcInputClass: "pf-c-form-control",
|
||||
kcFormGroupClass: "form-group",
|
||||
"kcLogoIdP-paypal": "fa fa-paypal",
|
||||
"kcInputClassCheckbox": "pf-c-check",
|
||||
"kcRecoveryCodesConfirmation": "kc-recovery-codes-confirmation",
|
||||
"kcFormPasswordVisibilityIconHide": "fa fa-eye-slash",
|
||||
"kcInputClassRadioInput": "pf-c-radio__input",
|
||||
"kcFormSocialAccountListButtonClass": "pf-c-button pf-m-control pf-m-block kc-social-item kc-social-gray",
|
||||
"kcInputClassCheckboxLabel": "pf-c-check__label",
|
||||
"kcFormOptionsClass": "col-xs-12 col-sm-12 col-md-12 col-lg-12",
|
||||
"kcFormHeaderClass": "login-pf-header",
|
||||
"kcFormSocialAccountGridItem": "pf-l-grid__item",
|
||||
"kcButtonPrimaryClass": "pf-m-primary",
|
||||
"kcInputHelperTextBeforeClass": "pf-c-form__helper-text pf-c-form__helper-text-before",
|
||||
kcInputClassCheckbox: "pf-c-check",
|
||||
kcRecoveryCodesConfirmation: "kc-recovery-codes-confirmation",
|
||||
kcFormPasswordVisibilityIconHide: "fa fa-eye-slash",
|
||||
kcInputClassRadioInput: "pf-c-radio__input",
|
||||
kcFormSocialAccountListButtonClass:
|
||||
"pf-c-button pf-m-control pf-m-block kc-social-item kc-social-gray",
|
||||
kcInputClassCheckboxLabel: "pf-c-check__label",
|
||||
kcFormOptionsClass: "col-xs-12 col-sm-12 col-md-12 col-lg-12",
|
||||
kcFormHeaderClass: "login-pf-header",
|
||||
kcFormSocialAccountGridItem: "pf-l-grid__item",
|
||||
kcButtonPrimaryClass: "pf-m-primary",
|
||||
kcInputHelperTextBeforeClass:
|
||||
"pf-c-form__helper-text pf-c-form__helper-text-before",
|
||||
"kcLogoIdP-github": "fa fa-github",
|
||||
"kcLabelClass": "pf-c-form__label pf-c-form__label-text"
|
||||
kcLabelClass: "pf-c-form__label pf-c-form__label-text"
|
||||
}
|
||||
});
|
||||
|
@ -108,11 +108,11 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
const { kcContext, i18n, doMakeUserConfirmPassword } = params;
|
||||
|
||||
const { insertScriptTags } = useInsertScriptTags({
|
||||
"scriptTags": Object.keys(kcContext.profile?.html5DataAnnotations ?? {})
|
||||
scriptTags: Object.keys(kcContext.profile?.html5DataAnnotations ?? {})
|
||||
.filter(key => key !== "kcMultivalued" && key !== "kcNumberFormat") // NOTE: Keycloakify handles it.
|
||||
.map(key => ({
|
||||
"type": "module",
|
||||
"src": `${kcContext.url.resourcesPath}/js/${key}.js`
|
||||
type: "module",
|
||||
src: `${kcContext.url.resourcesPath}/js/${key}.js`
|
||||
}))
|
||||
});
|
||||
|
||||
@ -146,15 +146,15 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
.filter(name => (name !== "username" ? true : !kcContext.realm.registrationEmailAsUsername))
|
||||
.map(name =>
|
||||
id<Attribute>({
|
||||
"name": name,
|
||||
"displayName": id<`\${${MessageKey}}`>(`\${${name}}`),
|
||||
"required": true,
|
||||
"value": (kcContext.register as any).formData[name] ?? "",
|
||||
"html5DataAnnotations": {},
|
||||
"readOnly": false,
|
||||
"validators": {},
|
||||
"annotations": {},
|
||||
"autocomplete": (() => {
|
||||
name: name,
|
||||
displayName: id<`\${${MessageKey}}`>(`\${${name}}`),
|
||||
required: true,
|
||||
value: (kcContext.register as any).formData[name] ?? "",
|
||||
html5DataAnnotations: {},
|
||||
readOnly: false,
|
||||
validators: {},
|
||||
annotations: {},
|
||||
autocomplete: (() => {
|
||||
switch (name) {
|
||||
case "email":
|
||||
return "email";
|
||||
@ -174,15 +174,15 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
.filter(name => (name !== "username" ? true : (kcContext.user as any).editUsernameAllowed))
|
||||
.map(name =>
|
||||
id<Attribute>({
|
||||
"name": name,
|
||||
"displayName": id<`\${${MessageKey}}`>(`\${${name}}`),
|
||||
"required": true,
|
||||
"value": (kcContext as any).user[name] ?? "",
|
||||
"html5DataAnnotations": {},
|
||||
"readOnly": false,
|
||||
"validators": {},
|
||||
"annotations": {},
|
||||
"autocomplete": (() => {
|
||||
name: name,
|
||||
displayName: id<`\${${MessageKey}}`>(`\${${name}}`),
|
||||
required: true,
|
||||
value: (kcContext as any).user[name] ?? "",
|
||||
html5DataAnnotations: {},
|
||||
readOnly: false,
|
||||
validators: {},
|
||||
annotations: {},
|
||||
autocomplete: (() => {
|
||||
switch (name) {
|
||||
case "email":
|
||||
return "email";
|
||||
@ -200,15 +200,15 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
//NOTE: Handle legacy update-email.ftl
|
||||
return [
|
||||
id<Attribute>({
|
||||
"name": "email",
|
||||
"displayName": id<`\${${MessageKey}}`>(`\${email}`),
|
||||
"required": true,
|
||||
"value": (kcContext.email as any).value ?? "",
|
||||
"html5DataAnnotations": {},
|
||||
"readOnly": false,
|
||||
"validators": {},
|
||||
"annotations": {},
|
||||
"autocomplete": "email"
|
||||
name: "email",
|
||||
displayName: id<`\${${MessageKey}}`>(`\${email}`),
|
||||
required: true,
|
||||
value: (kcContext.email as any).value ?? "",
|
||||
html5DataAnnotations: {},
|
||||
readOnly: false,
|
||||
validators: {},
|
||||
annotations: {},
|
||||
autocomplete: "email"
|
||||
})
|
||||
];
|
||||
}
|
||||
@ -228,11 +228,11 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
|
||||
return id<Attribute>({
|
||||
...rest,
|
||||
"group": {
|
||||
"name": group,
|
||||
"displayHeader": groupDisplayHeader,
|
||||
"displayDescription": groupDisplayDescription,
|
||||
"html5DataAnnotations": {}
|
||||
group: {
|
||||
name: group,
|
||||
displayHeader: groupDisplayHeader,
|
||||
displayDescription: groupDisplayDescription,
|
||||
html5DataAnnotations: {}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -257,28 +257,28 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
|
||||
syntheticAttributes.push(
|
||||
{
|
||||
"name": "password",
|
||||
"displayName": id<`\${${MessageKey}}`>("${password}"),
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"validators": {},
|
||||
"annotations": {},
|
||||
"autocomplete": "new-password",
|
||||
"html5DataAnnotations": {},
|
||||
name: "password",
|
||||
displayName: id<`\${${MessageKey}}`>("${password}"),
|
||||
required: true,
|
||||
readOnly: false,
|
||||
validators: {},
|
||||
annotations: {},
|
||||
autocomplete: "new-password",
|
||||
html5DataAnnotations: {},
|
||||
// NOTE: Compat with Keycloak version prior to 24
|
||||
...({ "groupAnnotations": {} } as {})
|
||||
...({ groupAnnotations: {} } as {})
|
||||
},
|
||||
{
|
||||
"name": "password-confirm",
|
||||
"displayName": id<`\${${MessageKey}}`>("${passwordConfirm}"),
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"validators": {},
|
||||
"annotations": {},
|
||||
"html5DataAnnotations": {},
|
||||
"autocomplete": "new-password",
|
||||
name: "password-confirm",
|
||||
displayName: id<`\${${MessageKey}}`>("${passwordConfirm}"),
|
||||
required: true,
|
||||
readOnly: false,
|
||||
validators: {},
|
||||
annotations: {},
|
||||
html5DataAnnotations: {},
|
||||
autocomplete: "new-password",
|
||||
// NOTE: Compat with Keycloak version prior to 24
|
||||
...({ "groupAnnotations": {} } as {})
|
||||
...({ groupAnnotations: {} } as {})
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -288,7 +288,10 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
})();
|
||||
|
||||
const initialFormFieldState = (() => {
|
||||
const out: { attribute: Attribute; valueOrValues: string | string[] }[] = [];
|
||||
const out: {
|
||||
attribute: Attribute;
|
||||
valueOrValues: string | string[];
|
||||
}[] = [];
|
||||
|
||||
for (const attribute of syntheticAttributes) {
|
||||
handle_multi_valued_attribute: {
|
||||
@ -324,7 +327,7 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
|
||||
out.push({
|
||||
attribute,
|
||||
"valueOrValues": values
|
||||
valueOrValues: values
|
||||
});
|
||||
|
||||
continue;
|
||||
@ -332,7 +335,7 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
|
||||
out.push({
|
||||
attribute,
|
||||
"valueOrValues": attribute.value ?? ""
|
||||
valueOrValues: attribute.value ?? ""
|
||||
});
|
||||
}
|
||||
|
||||
@ -340,14 +343,14 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
})();
|
||||
|
||||
const initialState: internal.State = {
|
||||
"formFieldStates": initialFormFieldState.map(({ attribute, valueOrValues }) => ({
|
||||
formFieldStates: initialFormFieldState.map(({ attribute, valueOrValues }) => ({
|
||||
attribute,
|
||||
"errors": getErrors({
|
||||
"attributeName": attribute.name,
|
||||
"formFieldStates": initialFormFieldState
|
||||
errors: getErrors({
|
||||
attributeName: attribute.name,
|
||||
formFieldStates: initialFormFieldState
|
||||
}),
|
||||
"hasLostFocusAtLeastOnce": valueOrValues instanceof Array ? valueOrValues.map(() => false) : false,
|
||||
"valueOrValues": valueOrValues
|
||||
hasLostFocusAtLeastOnce: valueOrValues instanceof Array ? valueOrValues.map(() => false) : false,
|
||||
valueOrValues: valueOrValues
|
||||
}))
|
||||
};
|
||||
|
||||
@ -381,8 +384,8 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
}
|
||||
|
||||
formFieldState.errors = getErrors({
|
||||
"attributeName": formAction.name,
|
||||
"formFieldStates": state.formFieldStates
|
||||
attributeName: formAction.name,
|
||||
formFieldStates: state.formFieldStates
|
||||
});
|
||||
|
||||
update_password_confirm: {
|
||||
@ -395,9 +398,9 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
}
|
||||
|
||||
state = reducer(state, {
|
||||
"action": "update",
|
||||
"name": "password-confirm",
|
||||
"valueOrValues": formAction.valueOrValues
|
||||
action: "update",
|
||||
name: "password-confirm",
|
||||
valueOrValues: formAction.valueOrValues
|
||||
});
|
||||
}
|
||||
|
||||
@ -421,9 +424,9 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
|
||||
const formState: FormState = useMemo(
|
||||
() => ({
|
||||
"formFieldStates": state.formFieldStates.map(
|
||||
formFieldStates: state.formFieldStates.map(
|
||||
({ errors, hasLostFocusAtLeastOnce: hasLostFocusAtLeastOnceOrArr, attribute, ...valueOrValuesWrap }) => ({
|
||||
"displayableErrors": errors.filter(error => {
|
||||
displayableErrors: errors.filter(error => {
|
||||
const hasLostFocusAtLeastOnce =
|
||||
typeof hasLostFocusAtLeastOnceOrArr === "boolean"
|
||||
? hasLostFocusAtLeastOnceOrArr
|
||||
@ -482,7 +485,7 @@ export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTy
|
||||
...valueOrValuesWrap
|
||||
})
|
||||
),
|
||||
"isFormSubmittable": state.formFieldStates.every(({ errors }) => errors.length === 0)
|
||||
isFormSubmittable: state.formFieldStates.every(({ errors }) => errors.length === 0)
|
||||
}),
|
||||
[state]
|
||||
);
|
||||
@ -501,7 +504,13 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const { msg, msgStr, advancedMsg, advancedMsgStr } = i18n;
|
||||
|
||||
const getErrors = useConstCallback(
|
||||
(params: { attributeName: string; formFieldStates: { attribute: Attribute; valueOrValues: string | string[] }[] }): FormFieldError[] => {
|
||||
(params: {
|
||||
attributeName: string;
|
||||
formFieldStates: {
|
||||
attribute: Attribute;
|
||||
valueOrValues: string | string[];
|
||||
}[];
|
||||
}): FormFieldError[] => {
|
||||
const { attributeName, formFieldStates } = params;
|
||||
|
||||
const formFieldState = formFieldStates.find(({ attribute }) => attribute.name === attributeName);
|
||||
@ -572,10 +581,10 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
return [
|
||||
{
|
||||
errorMessageStr,
|
||||
"errorMessage": <span key={0}>{errorMessageStr}</span>,
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "server"
|
||||
errorMessage: <span key={0}>{errorMessageStr}</span>,
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "server"
|
||||
}
|
||||
}
|
||||
];
|
||||
@ -598,19 +607,19 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
.map((...[, index]) => {
|
||||
const specificValueErrors = getErrors({
|
||||
attributeName,
|
||||
"formFieldStates": formFieldStates.map(formFieldState => {
|
||||
formFieldStates: formFieldStates.map(formFieldState => {
|
||||
if (formFieldState.attribute.name === attributeName) {
|
||||
assert(formFieldState.valueOrValues instanceof Array);
|
||||
return {
|
||||
"attribute": {
|
||||
attribute: {
|
||||
...attribute,
|
||||
"annotations": {
|
||||
annotations: {
|
||||
...attribute.annotations,
|
||||
"inputType": undefined
|
||||
inputType: undefined
|
||||
},
|
||||
"multivalued": false
|
||||
multivalued: false
|
||||
},
|
||||
"valueOrValues": formFieldState.valueOrValues[index]
|
||||
valueOrValues: formFieldState.valueOrValues[index]
|
||||
};
|
||||
}
|
||||
|
||||
@ -626,7 +635,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
|
||||
return true;
|
||||
})
|
||||
.map((error): FormFieldError => ({ ...error, "fieldIndex": index }));
|
||||
.map(
|
||||
(error): FormFieldError => ({
|
||||
...error,
|
||||
fieldIndex: index
|
||||
})
|
||||
);
|
||||
})
|
||||
.reduce((acc, errors) => [...acc, ...errors], []);
|
||||
|
||||
@ -642,12 +656,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["error-user-attribute-required"] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "other",
|
||||
"rule": "requiredField"
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "other",
|
||||
rule: "requiredField"
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -696,12 +710,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
|
||||
return [
|
||||
{
|
||||
"errorMessage": <Fragment key={0}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "validator",
|
||||
"name": validatorName
|
||||
errorMessage: <Fragment key={0}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "validator",
|
||||
name: validatorName
|
||||
}
|
||||
}
|
||||
];
|
||||
@ -740,12 +754,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["invalidPasswordMinLengthMessage", `${minLength}`] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "passwordPolicy",
|
||||
"name": policyName
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "passwordPolicy",
|
||||
name: policyName
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -768,12 +782,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["invalidPasswordMinDigitsMessage", `${minNumberOfDigits}`] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "passwordPolicy",
|
||||
"name": policyName
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "passwordPolicy",
|
||||
name: policyName
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -798,12 +812,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["invalidPasswordMinLowerCaseCharsMessage", `${minNumberOfLowerCaseChar}`] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "passwordPolicy",
|
||||
"name": policyName
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "passwordPolicy",
|
||||
name: policyName
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -828,12 +842,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["invalidPasswordMinUpperCaseCharsMessage", `${minNumberOfUpperCaseChar}`] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "passwordPolicy",
|
||||
"name": policyName
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "passwordPolicy",
|
||||
name: policyName
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -856,12 +870,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["invalidPasswordMinSpecialCharsMessage", `${minNumberOfSpecialChar}`] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "passwordPolicy",
|
||||
"name": policyName
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "passwordPolicy",
|
||||
name: policyName
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -906,12 +920,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["invalidPasswordNotUsernameMessage"] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "passwordPolicy",
|
||||
"name": policyName
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "passwordPolicy",
|
||||
name: policyName
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -944,12 +958,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["invalidPasswordNotEmailMessage"] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "passwordPolicy",
|
||||
"name": policyName
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "passwordPolicy",
|
||||
name: policyName
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -977,12 +991,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["invalidPasswordConfirmMessage"] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "other",
|
||||
"rule": "passwordConfirmMatchesPassword"
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "other",
|
||||
rule: "passwordConfirmMatchesPassword"
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1001,12 +1015,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["error-user-attribute-required"] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "other",
|
||||
"rule": "requiredField"
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "other",
|
||||
rule: "requiredField"
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1027,17 +1041,17 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
}
|
||||
|
||||
const source: FormFieldError.Source = {
|
||||
"type": "validator",
|
||||
"name": validatorName
|
||||
type: "validator",
|
||||
name: validatorName
|
||||
};
|
||||
|
||||
if (max && value.length > parseInt(`${max}`)) {
|
||||
const msgArgs = ["error-invalid-length-too-long", `${max}`] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source
|
||||
});
|
||||
}
|
||||
@ -1046,9 +1060,9 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["error-invalid-length-too-short", `${min}`] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source
|
||||
});
|
||||
}
|
||||
@ -1076,12 +1090,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = [errorMessageKey ?? id<MessageKey>("shouldMatchPattern"), pattern] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{advancedMsg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": advancedMsgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "validator",
|
||||
"name": validatorName
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{advancedMsg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: advancedMsgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "validator",
|
||||
name: validatorName
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1115,12 +1129,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = [id<MessageKey>("invalidEmailMessage")] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "validator",
|
||||
"name": validatorName
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "validator",
|
||||
name: validatorName
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1143,17 +1157,17 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const intValue = parseInt(value);
|
||||
|
||||
const source: FormFieldError.Source = {
|
||||
"type": "validator",
|
||||
"name": validatorName
|
||||
type: "validator",
|
||||
name: validatorName
|
||||
};
|
||||
|
||||
if (isNaN(intValue)) {
|
||||
const msgArgs = ["mustBeAnInteger"] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source
|
||||
});
|
||||
|
||||
@ -1164,9 +1178,9 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["error-number-out-of-range-too-big", `${max}`] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source
|
||||
});
|
||||
|
||||
@ -1177,9 +1191,9 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = ["error-number-out-of-range-too-small", `${min}`] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": msgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{msg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: msgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source
|
||||
});
|
||||
|
||||
@ -1207,12 +1221,12 @@ function useGetErrors(params: { kcContext: Pick<KcContextLike, "messagesPerField
|
||||
const msgArgs = [id<MessageKey>("notAValidOption")] as const;
|
||||
|
||||
errors.push({
|
||||
"errorMessage": <Fragment key={`${attributeName}-${errors.length}`}>{advancedMsg(...msgArgs)}</Fragment>,
|
||||
"errorMessageStr": advancedMsgStr(...msgArgs),
|
||||
"fieldIndex": undefined,
|
||||
"source": {
|
||||
"type": "validator",
|
||||
"name": validatorName
|
||||
errorMessage: <Fragment key={`${attributeName}-${errors.length}`}>{advancedMsg(...msgArgs)}</Fragment>,
|
||||
errorMessageStr: advancedMsgStr(...msgArgs),
|
||||
fieldIndex: undefined,
|
||||
source: {
|
||||
type: "validator",
|
||||
name: validatorName
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -19,12 +19,18 @@ export default function DeleteAccountConfirm(props: PageProps<Extract<KcContext,
|
||||
return (
|
||||
<Template {...{ kcContext, i18n, doUseDefaultCss, classes }} headerNode={msg("deleteAccountConfirm")}>
|
||||
<form action={url.loginAction} className="form-vertical" method="post">
|
||||
<div className="alert alert-warning" style={{ "marginTop": "0", "marginBottom": "30px" }}>
|
||||
<div className="alert alert-warning" style={{ marginTop: "0", marginBottom: "30px" }}>
|
||||
<span className="pficon pficon-warning-triangle-o"></span>
|
||||
{msg("irreversibleAction")}
|
||||
</div>
|
||||
<p>{msg("deletingImplies")}</p>
|
||||
<ul style={{ "color": "#72767b", "listStyle": "disc", "listStylePosition": "inside" }}>
|
||||
<ul
|
||||
style={{
|
||||
color: "#72767b",
|
||||
listStyle: "disc",
|
||||
listStylePosition: "inside"
|
||||
}}
|
||||
>
|
||||
<li>{msg("loggingOutImmediately")}</li>
|
||||
<li>{msg("errasingData")}</li>
|
||||
</ul>
|
||||
@ -38,7 +44,7 @@ export default function DeleteAccountConfirm(props: PageProps<Extract<KcContext,
|
||||
{triggered_from_aia && (
|
||||
<button
|
||||
className={clsx(getClassName("kcButtonClass"), getClassName("kcButtonDefaultClass"), getClassName("kcButtonLargeClass"))}
|
||||
style={{ "marginLeft": "calc(100% - 220px)" }}
|
||||
style={{ marginLeft: "calc(100% - 220px)" }}
|
||||
type="submit"
|
||||
name="cancel-aia"
|
||||
value="true"
|
||||
|
@ -27,7 +27,7 @@ export default function FrontchannelLogout(props: PageProps<Extract<KcContext, {
|
||||
{logout.clients.map(client => (
|
||||
<li key={client.name}>
|
||||
{client.name}
|
||||
<iframe src={client.frontChannelLogoutUrl} style={{ "display": "none" }} />
|
||||
<iframe src={client.frontChannelLogoutUrl} style={{ display: "none" }} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
@ -21,10 +21,10 @@ export default function LoginRecoveryAuthnCodeConfig(props: PageProps<Extract<Kc
|
||||
const { msg, msgStr } = i18n;
|
||||
|
||||
const { insertScriptTags } = useInsertScriptTags({
|
||||
"scriptTags": [
|
||||
scriptTags: [
|
||||
{
|
||||
"type": "text/javascript",
|
||||
"textContent": `
|
||||
type: "text/javascript",
|
||||
textContent: `
|
||||
|
||||
/* copy recovery codes */
|
||||
function copyRecoveryCodes() {
|
||||
|
@ -32,18 +32,18 @@ export default function WebauthnAuthenticate(props: PageProps<Extract<KcContext,
|
||||
const { msg, msgStr } = i18n;
|
||||
|
||||
const { insertScriptTags } = useInsertScriptTags({
|
||||
"scriptTags": [
|
||||
scriptTags: [
|
||||
{
|
||||
"type": "text/javascript",
|
||||
"src": `${url.resourcesCommonPath}/node_modules/jquery/dist/jquery.min.js`
|
||||
type: "text/javascript",
|
||||
src: `${url.resourcesCommonPath}/node_modules/jquery/dist/jquery.min.js`
|
||||
},
|
||||
{
|
||||
"type": "text/javascript",
|
||||
"src": `${url.resourcesPath}/js/base64url.js`
|
||||
type: "text/javascript",
|
||||
src: `${url.resourcesPath}/js/base64url.js`
|
||||
},
|
||||
{
|
||||
"type": "text/javascript",
|
||||
"textContent": `
|
||||
type: "text/javascript",
|
||||
textContent: `
|
||||
|
||||
function webAuthnAuthenticate() {
|
||||
let isUserIdentified = ${isUserIdentified};
|
||||
@ -206,7 +206,10 @@ export default function WebauthnAuthenticate(props: PageProps<Extract<KcContext,
|
||||
className={getClassName("kcSelectAuthListItemDescriptionClass")}
|
||||
>
|
||||
{authenticator.transports.displayNameProperties
|
||||
.map((nameProperty, i, arr) => ({ nameProperty, "hasNext": i !== arr.length - 1 }))
|
||||
.map((nameProperty, i, arr) => ({
|
||||
nameProperty,
|
||||
hasNext: i !== arr.length - 1
|
||||
}))
|
||||
.map(({ nameProperty, hasNext }) => (
|
||||
<Fragment key={nameProperty}>
|
||||
<span>{msg(nameProperty)}</span>
|
||||
|
@ -35,18 +35,18 @@ export default function WebauthnRegister(props: PageProps<Extract<KcContext, { p
|
||||
const { msg, msgStr } = i18n;
|
||||
|
||||
const { insertScriptTags } = useInsertScriptTags({
|
||||
"scriptTags": [
|
||||
scriptTags: [
|
||||
{
|
||||
"type": "text/javascript",
|
||||
"src": `${url.resourcesCommonPath}/node_modules/jquery/dist/jquery.min.js`
|
||||
type: "text/javascript",
|
||||
src: `${url.resourcesCommonPath}/node_modules/jquery/dist/jquery.min.js`
|
||||
},
|
||||
{
|
||||
"type": "text/javascript",
|
||||
"src": `${url.resourcesPath}/js/base64url.js`
|
||||
type: "text/javascript",
|
||||
src: `${url.resourcesPath}/js/base64url.js`
|
||||
},
|
||||
{
|
||||
"type": "text/javascript",
|
||||
"textContent": `
|
||||
type: "text/javascript",
|
||||
textContent: `
|
||||
function registerSecurityKey() {
|
||||
|
||||
// Check if WebAuthn is supported by this browser
|
||||
|
Reference in New Issue
Block a user