Remove profile.attributesByName from the kcContext
This commit is contained in:
@ -286,6 +286,9 @@ function decodeHtmlEntities(htmlStr){
|
||||
<#-- Remove realmAttributes added by https://github.com/jcputney/keycloak-theme-additional-info-extension for peace of mind. -->
|
||||
are_same_path(path, []) &&
|
||||
key == "realmAttributes"
|
||||
) || (
|
||||
<#-- attributesByName adds a lot of noise to the output and is not needed -->
|
||||
are_same_path(path, ["profile"]) && key == "attributesByName"
|
||||
)
|
||||
>
|
||||
<#local out_seq += ["/*" + path?join(".") + "." + key + " excluded*/"]>
|
||||
|
@ -586,7 +586,6 @@ export declare namespace KcContext {
|
||||
|
||||
export type UserProfile = {
|
||||
attributes: Attribute[];
|
||||
attributesByName: Record<string, Attribute>;
|
||||
html5DataAnnotations?: Record<string, string>;
|
||||
};
|
||||
|
||||
|
@ -39,9 +39,9 @@ export function createGetKcContext<
|
||||
if (mockPageId !== undefined && realKcContext === undefined) {
|
||||
//TODO maybe trow if no mock fo custom page
|
||||
|
||||
warn_that_mock_is_enbaled: {
|
||||
warn_that_mock_is_enabled: {
|
||||
if (isStorybook) {
|
||||
break warn_that_mock_is_enbaled;
|
||||
break warn_that_mock_is_enabled;
|
||||
}
|
||||
|
||||
console.log(
|
||||
@ -118,7 +118,6 @@ export function createGetKcContext<
|
||||
const { attributes } = kcContextDefaultMock.profile;
|
||||
|
||||
id<KcContext.Register>(kcContext).profile.attributes = [];
|
||||
id<KcContext.Register>(kcContext).profile.attributesByName = {};
|
||||
|
||||
const partialAttributes = [
|
||||
...((
|
||||
@ -153,9 +152,6 @@ export function createGetKcContext<
|
||||
id<KcContext.Register>(kcContext).profile.attributes.push(
|
||||
augmentedAttribute
|
||||
);
|
||||
id<KcContext.Register>(kcContext).profile.attributesByName[
|
||||
augmentedAttribute.name
|
||||
] = augmentedAttribute;
|
||||
});
|
||||
|
||||
partialAttributes
|
||||
@ -174,9 +170,6 @@ export function createGetKcContext<
|
||||
id<KcContext.Register>(kcContext).profile.attributes.push(
|
||||
partialAttribute as any
|
||||
);
|
||||
id<KcContext.Register>(kcContext).profile.attributesByName[
|
||||
name
|
||||
] = partialAttribute as any;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -75,10 +75,6 @@ const attributes: Attribute[] = [
|
||||
}
|
||||
];
|
||||
|
||||
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 = {
|
||||
@ -269,8 +265,7 @@ export const kcContextMocks = [
|
||||
recaptchaRequired: false,
|
||||
pageId: "register.ftl",
|
||||
profile: {
|
||||
attributes,
|
||||
attributesByName
|
||||
attributes
|
||||
},
|
||||
scripts: [
|
||||
//"https://www.google.com/recaptcha/api.js"
|
||||
@ -421,8 +416,7 @@ export const kcContextMocks = [
|
||||
...kcContextCommonMock,
|
||||
pageId: "login-update-profile.ftl",
|
||||
profile: {
|
||||
attributes,
|
||||
attributesByName
|
||||
attributes
|
||||
}
|
||||
}),
|
||||
id<KcContext.LoginIdpLinkConfirm>({
|
||||
@ -478,20 +472,14 @@ export const kcContextMocks = [
|
||||
...kcContextCommonMock,
|
||||
pageId: "idp-review-user-profile.ftl",
|
||||
profile: {
|
||||
attributes,
|
||||
attributesByName
|
||||
attributes
|
||||
}
|
||||
}),
|
||||
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])
|
||||
)
|
||||
attributes: attributes.filter(attribute => attribute.name === "email")
|
||||
}
|
||||
}),
|
||||
id<KcContext.SelectAuthenticator>({
|
||||
|
Reference in New Issue
Block a user