Fix for #142
Former-commit-id: e90d48532a52279e1dc201a4a608d7d4feee924f [formerly d2b7a5372ad7bb2b664f205cf0b7b82cd4741cc4] [formerly eec7d5cf1cfc2f7f8351bbac0787de8a53b5e9d8 [formerly 40b31bd29119109e7c8ee6168da9db72fb794ba8]] Former-commit-id: dbfbc3c849a526345848c56be7db48de0eadba5d [formerly 287567052912b6da7bc379bc690a7006d81d0701] Former-commit-id: 8d42c024c830c2f783cfc75f06b76b355029cca8
This commit is contained in:
parent
871836f16d
commit
c5b8aee22f
17
users.go
17
users.go
|
@ -263,8 +263,15 @@ func usersPutHandler(c *RequestContext, w http.ResponseWriter, r *http.Request)
|
||||||
u.Commands = []string{}
|
u.Commands = []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
ouser, ok := c.FM.Users[u.Username]
|
var ouser *User
|
||||||
if !ok {
|
for _, user := range c.FM.Users {
|
||||||
|
if user.ID == id {
|
||||||
|
ouser = user
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ouser == nil {
|
||||||
return http.StatusNotFound, nil
|
return http.StatusNotFound, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,6 +299,12 @@ func usersPutHandler(c *RequestContext, w http.ResponseWriter, r *http.Request)
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the user changed the username, delete the old user
|
||||||
|
// from the in-memory user map.
|
||||||
|
if ouser.Username != u.Username {
|
||||||
|
delete(c.FM.Users, ouser.Username)
|
||||||
|
}
|
||||||
|
|
||||||
c.FM.Users[u.Username] = &u
|
c.FM.Users[u.Username] = &u
|
||||||
return http.StatusOK, nil
|
return http.StatusOK, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue