From 87ed9884ffa100adb273b52e35b203c995394659 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Sat, 11 May 2024 22:48:15 +0200 Subject: [PATCH] Update the getKcContext function --- src/login/kcContext/createGetKcContext.ts | 30 +++++++++-------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/login/kcContext/createGetKcContext.ts b/src/login/kcContext/createGetKcContext.ts index a673a0de..13b0e2b8 100644 --- a/src/login/kcContext/createGetKcContext.ts +++ b/src/login/kcContext/createGetKcContext.ts @@ -86,25 +86,17 @@ export function createGetKcContext(kcContext).profile.attributes = []; - id(kcContext).profile.attributesByName = {}; + id(kcContext).profile.attributes = []; + id(kcContext).profile.attributesByName = {}; - const partialAttributes = [ - ...((partialKcContextCustomMock as DeepPartial).profile?.attributes ?? []) - ].filter(exclude(undefined)); + const partialAttributes = [...((partialKcContextCustomMock as DeepPartial).profile?.attributes ?? [])].filter( + exclude(undefined) + ); attributes.forEach(attribute => { const partialAttribute = partialAttributes.find(({ name }) => name === attribute.name); @@ -125,8 +117,8 @@ export function createGetKcContext(kcContext).profile.attributes.push(augmentedAttribute); - id(kcContext).profile.attributesByName[augmentedAttribute.name] = augmentedAttribute; + id(kcContext).profile.attributes.push(augmentedAttribute); + id(kcContext).profile.attributesByName[augmentedAttribute.name] = augmentedAttribute; }); partialAttributes @@ -136,8 +128,8 @@ export function createGetKcContext(kcContext).profile.attributes.push(partialAttribute as any); - id(kcContext).profile.attributesByName[name] = partialAttribute as any; + id(kcContext).profile.attributes.push(partialAttribute as any); + id(kcContext).profile.attributesByName[name] = partialAttribute as any; }); } }