From 24842adb92e7df1f2ba780b70055676f96206948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Tue, 9 May 2023 14:08:56 +0200 Subject: [PATCH] #896: fix spelling of SSO field FederatedID - upper-cased D is required by API --- lib/metadataTypes/User.js | 18 +++++++++++++----- .../definitions/User.definition.js | 8 ++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/metadataTypes/User.js b/lib/metadataTypes/User.js index 6e30896d0..d53a3ff75 100644 --- a/lib/metadataTypes/User.js +++ b/lib/metadataTypes/User.js @@ -149,25 +149,33 @@ class User extends MetadataType { // convert SSO / Federation Token into API compliant format if (metadata.SsoIdentity || metadata.SsoIdentities) { const ssoIdentity = {}; + let error = false; if (metadata.SsoIdentity) { // assume metadata.SsoIdentity is an object ssoIdentity.IsActive = metadata.SsoIdentity.IsActive; - ssoIdentity.FederatedId = metadata.SsoIdentity.FederatedId; + ssoIdentity.FederatedID = metadata.SsoIdentity.FederatedID; delete metadata.SsoIdentity; } else if (Array.isArray(metadata.SsoIdentities)) { // be nice and allow SsoIdentities as an alternative if its an array of objects ssoIdentity.IsActive = metadata.SsoIdentities[0].IsActive; - ssoIdentity.FederatedId = metadata.SsoIdentities[0].FederatedId; + ssoIdentity.FederatedID = metadata.SsoIdentities[0].FederatedID; } else if ( Array.isArray(metadata.SsoIdentities?.SsoIdentity) && metadata.SsoIdentities?.SsoIdentity.length ) { // API-compliant format already provided; just use it ssoIdentity.IsActive = metadata.SsoIdentities.SsoIdentity[0]?.IsActive; - ssoIdentity.FederatedId = metadata.SsoIdentities.SsoIdentity[0]?.FederatedId; + ssoIdentity.FederatedID = metadata.SsoIdentities.SsoIdentity[0]?.FederatedID; } else { + error = true; + } + if ( + (ssoIdentity.IsActive !== true && ssoIdentity.IsActive !== false) || + !ssoIdentity.FederatedID || + error + ) { throw new TypeError( - 'SsoIdentity should be an object with IsActive and FederatedId properties.' + 'SsoIdentity should be an object with IsActive and FederatedID properties.' ); } // if SsoIdentity is set, assume this was on purpose and bring it @@ -175,7 +183,7 @@ class User extends MetadataType { SsoIdentity: [ { IsActive: ssoIdentity.IsActive, - FederatedId: ssoIdentity.FederatedId, + FederatedID: ssoIdentity.FederatedID, }, ], }; diff --git a/lib/metadataTypes/definitions/User.definition.js b/lib/metadataTypes/definitions/User.definition.js index 691bdaadf..adae97e17 100644 --- a/lib/metadataTypes/definitions/User.definition.js +++ b/lib/metadataTypes/definitions/User.definition.js @@ -196,19 +196,19 @@ module.exports = { retrieving: false, // retrieve not supported by API template: false, }, - 'SsoIdentities[]': { + 'SsoIdentities.SsoIdentity': { isCreateable: true, isUpdateable: true, - retrieving: false, + retrieving: false, // retrieve not supported by API template: false, }, - 'SsoIdentities[].IsActive': { + 'SsoIdentities.SsoIdentity[].IsActive': { isCreateable: true, isUpdateable: true, retrieving: false, template: false, }, - 'SsoIdentities[].FederatedID': { + 'SsoIdentities.SsoIdentity[].FederatedID': { isCreateable: true, isUpdateable: true, retrieving: false,