diff --git a/src/applicationManager.ts b/src/applicationManager.ts index 484d1ee..c56dbe2 100644 --- a/src/applicationManager.ts +++ b/src/applicationManager.ts @@ -581,18 +581,28 @@ export async function updateApplicationAppRoles({ /** * Necessary where an app role is deleted, they must all be disabled first. Easier to disable by default and enable when updating. */ -async function disableAppRoles(applicationId: string, token: string, appRoles: AppRoles) { +async function disableAppRoles( + applicationId: string, + token: string, + appRoles: AppRoles, +) { const app = await readApplication({ token, applicationId }); let appRolesJson: Array = app.appRoles; // Finds pairs of displayName and ID of app roles to compare existing app roles with incoming app roles - const incomingAppRolePairs = appRoles.map(({ displayName, id }) => `name:${displayName}_id:${id}`); - const existingAppRolePairs = appRolesJson.map(({ displayName, id }) => `name:${displayName}_id:${id}`); - const commonPairs = existingAppRolePairs.filter(pair => incomingAppRolePairs.includes(pair)); + const incomingAppRolePairs = appRoles.map( + ({ displayName, id }) => `name:${displayName}_id:${id}`, + ); + const existingAppRolePairs = appRolesJson.map( + ({ displayName, id }) => `name:${displayName}_id:${id}`, + ); + const commonPairs = existingAppRolePairs.filter((pair) => + incomingAppRolePairs.includes(pair), + ); // Break here if app roles are the same as current file - not disabling all roles if unnecessary - if(!(commonPairs.length < existingAppRolePairs.length)){ - return + if (!(commonPairs.length < existingAppRolePairs.length)) { + return; } // Keep fetched array of AppRoles but change enabled to false