Remove profile.attributesByName from the kcContext

This commit is contained in:
Joseph Garrone
2024-05-28 01:05:35 +02:00
parent fdfcd78f02
commit a217f617d8
4 changed files with 9 additions and 26 deletions

View File

@ -586,7 +586,6 @@ export declare namespace KcContext {
export type UserProfile = {
attributes: Attribute[];
attributesByName: Record<string, Attribute>;
html5DataAnnotations?: Record<string, string>;
};

View File

@ -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;
});
}
}

View File

@ -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>({