diff --git a/lib/metadataTypes/AccountUser.js b/lib/metadataTypes/AccountUser.js index 1ffa36e9a..7e2a3020d 100644 --- a/lib/metadataTypes/AccountUser.js +++ b/lib/metadataTypes/AccountUser.js @@ -77,6 +77,40 @@ class AccountUser extends MetadataType { metadata.Client = { ID: this.buObject.mid, }; + + if (metadata.SsoIdentity || metadata.SsoIdentities) { + const ssoIdentity = {}; + if (metadata.SsoIdentity) { + // assume metadata.SsoIdentity is an object + ssoIdentity.IsActive = metadata.SsoIdentity.IsActive; + 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; + } 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; + } else { + throw new TypeError( + 'SsoIdentity should be an object with IsActive and FederatedId properties.' + ); + } + // if SsoIdentity is set, assume this was on purpose and bring it + metadata.SsoIdentities = { + SsoIdentity: [ + { + IsActive: ssoIdentity.IsActive, + FederatedId: ssoIdentity.FederatedId, + }, + ], + }; + } return metadata; } /** diff --git a/lib/metadataTypes/definitions/AccountUser.definition.js b/lib/metadataTypes/definitions/AccountUser.definition.js index ab06bf93a..41122281f 100644 --- a/lib/metadataTypes/definitions/AccountUser.definition.js +++ b/lib/metadataTypes/definitions/AccountUser.definition.js @@ -137,9 +137,26 @@ module.exports = { skipValidation: false, }, SsoIdentities: { - // not supported by API - isCreateable: false, - isUpdateable: false, + isCreateable: true, + isUpdateable: true, + retrieving: false, // retrieve not supported by API + template: false, + }, + 'SsoIdentities[]': { + isCreateable: true, + isUpdateable: true, + retrieving: false, + template: false, + }, + 'SsoIdentities[].IsActive': { + isCreateable: true, + isUpdateable: true, + retrieving: false, + template: false, + }, + 'SsoIdentities[].FederatedID': { + isCreateable: true, + isUpdateable: true, retrieving: false, template: false, },