Skip to content

Commit

Permalink
remove gen reports role
Browse files Browse the repository at this point in the history
  • Loading branch information
mgtennant committed Nov 6, 2024
1 parent caf395c commit 8684a43
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 77 deletions.
78 changes: 2 additions & 76 deletions backend/src/admin/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class AdminService {

/**
* Searches for an IDIR user with the given search params and if only one is found
* then gives them the ticdi_admin & generate_documents roles in both IDIR and AzureIDIR
* then gives them the ticdi_admin role in both IDIR and AzureIDIR
*
* @param firstName
* @param lastName
Expand Down Expand Up @@ -214,23 +214,6 @@ export class AdminService {
console.log(err);
throw new Error('Failed to add idir ticdi_admin role');
});
await axios
.post(
addAdminUrl,
{
roleName: Role.GENERATE_DOCUMENTS,
username: username + '@idir',
operation: 'add',
},
{ headers: { Authorization: 'Bearer ' + bearerToken } }
)
.then((res) => {
return res.data;
})
.catch((err) => {
console.log(err);
throw new Error('Failed to add idir generate_documents role');
});
await axios
.post(
addAdminUrl,
Expand All @@ -248,23 +231,6 @@ export class AdminService {
console.log(err);
throw new Error('Failed to add azureidir ticdi_admin role');
});
await axios
.post(
addAdminUrl,
{
roleName: Role.GENERATE_DOCUMENTS,
username: username + '@azureidir',
operation: 'add',
},
{ headers: { Authorization: 'Bearer ' + bearerToken } }
)
.then((res) => {
return res.data;
})
.catch((err) => {
console.log(err);
throw new Error('Failed to add azureidir generate_documents role');
});
} catch (err) {
console.log(err);
}
Expand Down Expand Up @@ -307,7 +273,7 @@ export class AdminService {
}

/**
* Removes the ticdi_admin & generate_documents role from an IDIR user
* Removes the ticdi_admin role from an IDIR user
*
* @param username
* @returns null
Expand All @@ -317,9 +283,7 @@ export class AdminService {
const idirUsername = username?.split('@')[0].concat('@idir');
const azureidirUsername = username?.split('@')[0].concat('@azureidir');
const idirAdminUrl = `${process.env.users_api_base_url}/integrations/${process.env.integration_id}/${process.env.css_environment}/users/${idirUsername}/roles/${Role.TICDI_ADMIN}`;
const idirGDUrl = `${process.env.users_api_base_url}/integrations/${process.env.integration_id}/${process.env.css_environment}/users/${idirUsername}/roles/${Role.GENERATE_DOCUMENTS}`;
const azureidirAdminUrl = `${process.env.users_api_base_url}/integrations/${process.env.integration_id}/${process.env.css_environment}/users/${azureidirUsername}/roles/${Role.TICDI_ADMIN}`;
const azureidirGDUrl = `${process.env.users_api_base_url}/integrations/${process.env.integration_id}/${process.env.css_environment}/users/${azureidirUsername}/roles/${Role.GENERATE_DOCUMENTS}`;
try {
await axios
.delete(idirAdminUrl, {
Expand All @@ -339,25 +303,6 @@ export class AdminService {
return { error: 'Failed to remove idir_admin role' };
}
}
try {
await axios
.delete(idirGDUrl, {
headers: { Authorization: 'Bearer ' + bearerToken },
})
.then((res) => {
return res;
})
.catch((err) => {
throw err;
});
} catch (err) {
console.log(err.response.data);
if (err?.response?.data?.message?.includes('not associated')) {
// ignore error if user is not associated with the role
} else {
return { error: 'Failed to remove generate_documents role' };
}
}
try {
await axios
.delete(azureidirAdminUrl, {
Expand All @@ -377,25 +322,6 @@ export class AdminService {
return { error: 'Failed to remove idir_admin role' };
}
}
try {
await axios
.delete(azureidirGDUrl, {
headers: { Authorization: 'Bearer ' + bearerToken },
})
.then((res) => {
return res;
})
.catch((err) => {
throw err;
});
} catch (err) {
console.log(err.response.data);
if (err?.response?.data?.message?.includes('not associated')) {
// ignore error if user is not associated with the role
} else {
return { error: 'Failed to remove generate_documents role' };
}
}
return { error: null };
}

Expand Down
1 change: 0 additions & 1 deletion backend/src/enum/role.enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export enum Role {
TICDI_ADMIN = 'ticdi_admin',
GENERATE_DOCUMENTS = 'generate_documents',
}

0 comments on commit 8684a43

Please sign in to comment.