Fix for #142
parent
03755f6846
commit
40b31bd291
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