fix user update groups goroutine

This commit is contained in:
Adphi 2019-02-19 09:30:27 +01:00
parent a54ee4c2e6
commit 0551ffbca1

View File

@ -255,16 +255,16 @@ func (u *Users) Update(user *types.UserDetails) error {
for _, g := range original.Groups {
if !contains(user.Groups, g) {
wg.Add(1)
go func() {
go func(gr string) {
defer wg.Done()
if err := u.GroupRemove(user.ID, g); err != nil {
if err := u.GroupRemove(user.ID, gr); err != nil {
errs <- &types.UpdateError{
Field: "Groups/" + g,
Field: "Groups/" + gr,
Error: err,
}
}
errs <- nil
}()
}(g)
}
}
@ -272,16 +272,16 @@ func (u *Users) Update(user *types.UserDetails) error {
for _, g := range user.Groups {
if !contains(original.Groups, g) {
wg.Add(1)
go func() {
go func(gr string) {
defer wg.Done()
if err := u.GroupAdd(user.ID, g); err != nil {
if err := u.GroupAdd(user.ID, gr); err != nil {
errs <- &types.UpdateError{
Field: "Groups/" + g,
Field: "Groups/" + gr,
Error: err,
}
}
errs <- nil
}()
}(g)
}
}