Skip to content

Commit

Permalink
fix: uncomment delete code
Browse files Browse the repository at this point in the history
  • Loading branch information
NithinKuruba committed Jul 19, 2023
1 parent d20b15f commit 2d46d46
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions docker/kc-cron-job/remove-inactive-idir-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,6 @@ function handleError(error) {
}
}

function ignoreError(prom, errorValue = null) {
return prom.then(
(data) => data,
(err) => {
console.error(err);
return errorValue;
},
);
}

async function getUserRolesMappings(adminClient, userId) {
try {
const clientRoles = [];
Expand Down Expand Up @@ -339,20 +329,19 @@ async function removeUserFromCssApp(userGuid) {
'Content-Type': 'application/json',
Authorization: process.env.CSS_API_AUTH_SECRET,
};
const a = await axios.delete(`${process.env.CSS_API_URL}/users/${userGuid}`, { headers });
return a.status === 204 ? true : false;
const deleteRes = await axios.delete(`${process.env.CSS_API_URL}/users/${userGuid}`, { headers });
return deleteRes.status === 204 ? true : false;
} catch (err) {
console.error(err);
return false;
}
}

async function removeUserFromKc(adminClient, id) {
try {
await adminClient.users.del({ realm: 'standard', id });
return true;
} catch (err) {
console.error(err);
return false;
}
}

Expand Down Expand Up @@ -386,8 +375,8 @@ async function removeStaleUsersByEnv(env = 'dev', pgClient, runnerName, startFro
const userExistsAtWb = await checkUserExistsAtIDIM({ property: 'userGuid', matchKey: idir_user_guid, env });
if (!userExistsAtWb) {
const { realmRoles, clientRoles } = await getUserRolesMappings(adminClient, id);
// await removeUserFromKc(adminClient, id);
// const userDeletedAtCss = await removeUserFromCssApp(idir_user_guid);
await removeUserFromKc(adminClient, id);
const userDeletedAtCss = await removeUserFromCssApp(idir_user_guid);
const values = [
env,
id,
Expand Down

0 comments on commit 2d46d46

Please sign in to comment.