mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
Fix for #142
This commit is contained in:
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{}
|
||||
}
|
||||
|
||||
ouser, ok := c.FM.Users[u.Username]
|
||||
if !ok {
|
||||
var ouser *User
|
||||
for _, user := range c.FM.Users {
|
||||
if user.ID == id {
|
||||
ouser = user
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if ouser == nil {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
|
||||
@ -292,6 +299,12 @@ func usersPutHandler(c *RequestContext, w http.ResponseWriter, r *http.Request)
|
||||
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
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user