Skip to content

Commit

Permalink
#896: fix spelling of SSO field FederatedID - upper-cased D is requir…
Browse files Browse the repository at this point in the history
…ed by API
  • Loading branch information
JoernBerkefeld committed May 9, 2023
1 parent 7563fa6 commit 24842ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
18 changes: 13 additions & 5 deletions lib/metadataTypes/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,33 +149,41 @@ 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
metadata.SsoIdentities = {
SsoIdentity: [
{
IsActive: ssoIdentity.IsActive,
FederatedId: ssoIdentity.FederatedId,
FederatedID: ssoIdentity.FederatedID,
},
],
};
Expand Down
8 changes: 4 additions & 4 deletions lib/metadataTypes/definitions/User.definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 24842ad

Please sign in to comment.