Skip to content

Commit

Permalink
extract into private function
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorCapCoder committed Sep 29, 2023
1 parent 976fa19 commit 3150ac8
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,22 +201,24 @@ export class OidcProvisioningService {
}
);

await Promise.all(
existingGroupsOfUser.map(async (existingGroup: Group): Promise<void> => {
if (existingGroup.externalSource) {
const isGroupWithoutUser = !externalGroupsExternalSources.includes(existingGroup.externalSource);
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
if (isGroupWithoutUser) {
await this.removeUserFromGroup(externalUserId, existingGroup.externalSource);
}
}
});
}

const groupUsers: GroupUser[] = await this.groupService.getUsersOfGroup(existingGroup.externalSource); // TODO implement service and repo function
private async removeUserFromGroup(externalUserId: string, externalSource: ExternalSource): Promise<void> {
await this.groupService.deleteUserFromGroup(externalUserId, externalSource); // TODO implement service and repo function

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

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

0 comments on commit 3150ac8

Please sign in to comment.