mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: check permission to update username (#20139)
This commit is contained in:
@@ -753,6 +753,14 @@ func (api *API) putUserProfile(rw http.ResponseWriter, r *http.Request) {
|
||||
if !httpapi.Read(ctx, rw, r, ¶ms) {
|
||||
return
|
||||
}
|
||||
|
||||
// If caller wants to update user's username, they need "update_users" permission.
|
||||
// This is restricted to user admins only.
|
||||
if params.Username != user.Username && !api.Authorize(r, policy.ActionUpdate, user) {
|
||||
httpapi.ResourceNotFound(rw)
|
||||
return
|
||||
}
|
||||
|
||||
existentUser, err := api.Database.GetUserByEmailOrUsername(ctx, database.GetUserByEmailOrUsernameParams{
|
||||
Username: params.Username,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user