Skip to content

Commit

Permalink
Merge pull request #3684 from uselagoon/usergroup-subgroups
Browse files Browse the repository at this point in the history
fix: only set the subgroups of a parentgroup to the users group
  • Loading branch information
tobybellwood authored Mar 25, 2024
2 parents db06e2c + 4833e6b commit 9f0a171
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions services/api/src/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ export const User = (clients: {
continue
}
}
// only set the users role-group as the subgroup, this is because `loadGroupByName` retrieves all the subgroups not just the one the user is in
parentGroup.subGroups = [ug]
userGroups.push(parentGroup);
}
}
Expand Down
6 changes: 6 additions & 0 deletions services/api/src/resources/group/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const Helpers = (sqlClientPool: Pool) => {
for (const o in groups) {
projectGroups.push(await models.GroupModel.loadGroupById(groups[o]))
}
projectGroups.sort(function(a, b) {
return a.name.localeCompare(b.name);
});
return projectGroups
}
return []
Expand All @@ -57,6 +60,9 @@ export const Helpers = (sqlClientPool: Pool) => {
for (const o in groups) {
orgGroups.push(await models.GroupModel.loadGroupById(groups[o]))
}
orgGroups.sort(function(a, b) {
return a.name.localeCompare(b.name);
});
return orgGroups
}
return []
Expand Down

0 comments on commit 9f0a171

Please sign in to comment.