Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
move validate forward
  • Loading branch information
f0ssel committed May 27, 2022
commit 1b7ea13671c301656309f4b0dcd01539fbcf85fa
26 changes: 13 additions & 13 deletions coderd/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,19 @@ func (api *API) putUserPassword(rw http.ResponseWriter, r *http.Request) {
return
}

err := userpassword.Validate(params.Password)
if err != nil {
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
Errors: []httpapi.Error{
{
Field: "password",
Detail: err.Error(),
},
},
})
return
}

// we want to require old_password field if the user is changing their
// own password. This is to prevent a compromised session from being able
// to change password and lock out the user.
Expand All @@ -391,19 +404,6 @@ func (api *API) putUserPassword(rw http.ResponseWriter, r *http.Request) {
}
}

err := userpassword.Validate(params.Password)
if err != nil {
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
Errors: []httpapi.Error{
{
Field: "password",
Detail: err.Error(),
},
},
})
return
}

hashedPassword, err := userpassword.Hash(params.Password)
if err != nil {
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
Expand Down