Skip to content

Commit

Permalink
Made use of new load privs flag in a few places
Browse files Browse the repository at this point in the history
.. in the group extension
  • Loading branch information
markdicksonjr committed Feb 16, 2020
1 parent 6ca6de5 commit 9aea7ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions user/group/composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *Extension) LoadUserComposite(userId string) (*UserComposite, error) {
for _, m := range memberships {
groupIds = append(groupIds, m.GroupID)
}
groups, err := s.GetGroups(groupIds)
groups, err := s.GetGroups(groupIds, true)

if err != nil {
return nil, err
Expand All @@ -94,8 +94,9 @@ func (s *Extension) LoadUserComposite(userId string) (*UserComposite, error) {
composite.Groups = groups

// set the current group in the composite model we're returning
// TODO: check results of GetGroups above to avoid doing this load
if u.CurrentGroupID != nil {
g, err := s.GetGroups([]string{ *u.CurrentGroupID })
g, err := s.GetGroups([]string{ *u.CurrentGroupID }, true)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions user/group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ func (s *Extension) CreateGroup(name string) (nibbler.Group, error) {
return group, err
}

func (s *Extension) GetGroups(groupIds []string) ([]nibbler.Group, error) {
func (s *Extension) GetGroups(groupIds []string, includePrivileges bool) ([]nibbler.Group, error) {

// load the groups for the set of memberships
if len(groupIds) == 0 {
return []nibbler.Group{}, nil
}

return s.PersistenceExtension.GetGroupsById(groupIds)
return s.PersistenceExtension.GetGroupsById(groupIds, includePrivileges)
}

0 comments on commit 9aea7ac

Please sign in to comment.