Skip to content

Commit

Permalink
orchestration removal of group and groupUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorCapCoder committed Sep 29, 2023
1 parent ef2ed73 commit 976fa19
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,30 @@ export class OidcProvisioningService {
): Promise<void> {
const existingGroupsOfUser: Group[] = await this.groupService.findByUserId(externalUserId); // TODO implement service and repo function

const groupsWithoutUser: Group[] = await Promise.all(
existingGroupsOfUser.map(async (existingGroup: Group): Promise<Group> => {
// TODO check for existingGroup not in externalGroups[] and remove user from this group
const externalGroupsExternalSources: ExternalSource[] = externalGroups.forEach(
(externalGroup: ExternalGroupDto): ExternalSource => {
const externalGroupId: ExternalSource = { externalId: externalGroup.externalId, systemId };

return externalGroupId;
}
);

await Promise.all(
existingGroupsOfUser.map(async (existingGroup: Group): Promise<void> => {
if (existingGroup.externalSource) {
const isGroupWithoutUser = !externalGroupsExternalSources.includes(existingGroup.externalSource);

if (isGroupWithoutUser) {
await this.groupService.deleteUserFromGroup(externalUserId, existingGroup.externalSource); // TODO implement service and repo function

const groupUsers: GroupUser[] = await this.groupService.getUsersOfGroup(existingGroup.externalSource); // TODO implement service and repo function

if (groupUsers.length === 0) {
await this.groupService.deleteGroup(existingGroup.externalSource); // TODO implement service and repo function
}
}
}
})
);
// TODO remove all groupsWithoutUser.length === 0
}
}

0 comments on commit 976fa19

Please sign in to comment.