Skip to content

Commit

Permalink
Fix code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
reespozzi committed Jan 4, 2024
1 parent e40e383 commit 6c63eab
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/applicationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppRole> = 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
Expand Down

0 comments on commit 6c63eab

Please sign in to comment.