Skip to content

Commit

Permalink
quick fix user service hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
nettashviro committed Jan 26, 2022
1 parent c9d41ab commit 235b514
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/kartoffel/kartoffel.intergation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,17 @@ export class Kartoffel {
throw new ApplicationError(`Unknown Error: ${err} `);
}
const users: IKartoffelUser[] = res.data;
const generalUsers: IUser[] = users.map((user: IKartoffelUser) => {
if (dest && dest === (EXTERNAL_DESTS.CTS as any as string)) {
// Get the id that match to cts datasource and replace the return id to cts id
const userMatch: IDomainUser[] = user.domainUsers.filter((domainUser) => {
return ctsDatasource === domainUser.dataSource;
});
user.id = userMatch[0].uniqueID ? userMatch[0].uniqueID : user.id;
}
const usersWithRoles = users.filter(user => user?.hierarchy && !Array.isArray(user.hierarchy));
const generalUsers: IUser[] = usersWithRoles.map((user: IKartoffelUser) => {
if (dest && dest === (EXTERNAL_DESTS.CTS as any as string)) {
// Get the id that match to cts datasource and replace the return id to cts id
const userMatch: IDomainUser[] = user.domainUsers.filter((domainUser) => {
return ctsDatasource === domainUser.dataSource;
});
user.id = userMatch[0].uniqueID ? userMatch[0].uniqueID : user.id;
}

return this.setUser(user);
return this.setUser(user);
});
return generalUsers;
}
Expand Down

0 comments on commit 235b514

Please sign in to comment.