@@ -360,12 +360,12 @@ func (api *api) putUserSuspend(rw http.ResponseWriter, r *http.Request) {
360
360
httpapi .Write (rw , http .StatusOK , convertUser (suspendedUser , organizations ))
361
361
}
362
362
363
- func (api * api ) putUserPassword (rw http.ResponseWriter , r * http.Request ) error {
363
+ func (api * api ) putUserPassword (rw http.ResponseWriter , r * http.Request ) {
364
364
user := httpmw .UserParam (r )
365
365
366
366
var params codersdk.UpdateUserPasswordRequest
367
367
if ! httpapi .Read (rw , r , & params ) {
368
- return nil
368
+ return
369
369
}
370
370
371
371
// Check if the new password and the confirmation match
@@ -380,13 +380,15 @@ func (api *api) putUserPassword(rw http.ResponseWriter, r *http.Request) error {
380
380
Message : fmt .Sprintf ("The new password and the new password confirmation don't match" ),
381
381
Errors : requestErrors ,
382
382
})
383
- return nil
383
+ return
384
384
}
385
385
386
386
// Hash password and update it in the database
387
387
hashedPassword , hashError := userpassword .Hash (params .NewPassword )
388
388
if hashError != nil {
389
- return xerrors .Errorf ("hash password: %w" , hashError )
389
+ httpapi .Write (rw , http .StatusInternalServerError , httpapi.Response {
390
+ Message : fmt .Sprintf ("hash password: %s" , hashError .Error ()),
391
+ })
390
392
}
391
393
databaseError := api .Database .UpdateUserHashedPassword (r .Context (), database.UpdateUserHashedPasswordParams {
392
394
ID : user .ID ,
@@ -396,11 +398,10 @@ func (api *api) putUserPassword(rw http.ResponseWriter, r *http.Request) error {
396
398
httpapi .Write (rw , http .StatusInternalServerError , httpapi.Response {
397
399
Message : fmt .Sprintf ("put user password: %s" , databaseError .Error ()),
398
400
})
399
- return nil
401
+ return
400
402
}
401
403
402
404
httpapi .Write (rw , http .StatusNoContent , nil )
403
- return nil
404
405
}
405
406
406
407
func (api * api ) userRoles (rw http.ResponseWriter , r * http.Request ) {
0 commit comments