mirror of
https://github.com/paralus/paralus.git
synced 2026-05-06 16:36:46 +00:00
When adding users to group drop duplicate users (#50)
This commit is contained in:
@@ -223,7 +223,7 @@ func (s *groupService) createGroupAccountRelations(ctx context.Context, groupId
|
||||
// TODO: add transactions
|
||||
var grpaccs []models.GroupAccount
|
||||
var ugs []*authzv1.UserGroup
|
||||
for _, account := range group.GetSpec().GetUsers() {
|
||||
for _, account := range unique(group.GetSpec().GetUsers()) {
|
||||
// FIXME: do combined lookup
|
||||
entity, err := s.dao.GetIdByTraits(ctx, account, &models.KratosIdentities{})
|
||||
if err != nil {
|
||||
|
||||
13
pkg/service/utils.go
Normal file
13
pkg/service/utils.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package service
|
||||
|
||||
func unique(items []string) []string {
|
||||
keys := make(map[string]bool)
|
||||
list := []string{}
|
||||
for _, entry := range items {
|
||||
if _, value := keys[entry]; !value {
|
||||
keys[entry] = true
|
||||
list = append(list, entry)
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
Reference in New Issue
Block a user