Skip to content

Commit 30b8f15

Browse files
committed
Improve readbility
1 parent 355f163 commit 30b8f15

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

coderd/database/queries/users.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ WHERE
7070
-- name: GetUsers :many
7171
SELECT
7272
*
73-
FROM
73+
FROM
7474
users
7575
WHERE
7676
CASE

coderd/users.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,19 +384,20 @@ func (api *api) putUserPassword(rw http.ResponseWriter, r *http.Request) {
384384
}
385385

386386
// Hash password and update it in the database
387-
hashedPassword, hashError := userpassword.Hash(params.NewPassword)
388-
if hashError != nil {
387+
hashedPassword, err := userpassword.Hash(params.NewPassword)
388+
if err != nil {
389389
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
390-
Message: fmt.Sprintf("hash password: %s", hashError.Error()),
390+
Message: fmt.Sprintf("hash password: %s", err.Error()),
391391
})
392+
return
392393
}
393-
databaseError := api.Database.UpdateUserHashedPassword(r.Context(), database.UpdateUserHashedPasswordParams{
394+
err = api.Database.UpdateUserHashedPassword(r.Context(), database.UpdateUserHashedPasswordParams{
394395
ID: user.ID,
395396
HashedPassword: []byte(hashedPassword),
396397
})
397-
if databaseError != nil {
398+
if err != nil {
398399
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
399-
Message: fmt.Sprintf("put user password: %s", databaseError.Error()),
400+
Message: fmt.Sprintf("put user password: %s", err.Error()),
400401
})
401402
return
402403
}

codersdk/users.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ func (c *Client) SuspendUser(ctx context.Context, userID uuid.UUID) (User, error
187187
return user, json.NewDecoder(res.Body).Decode(&user)
188188
}
189189

190-
// Update user password
190+
// UpdateUserPassword updates a user password.
191+
// It calls PUT /users/{user}/password
191192
func (c *Client) UpdateUserPassword(ctx context.Context, userID uuid.UUID, req UpdateUserPasswordRequest) error {
192193
res, err := c.request(ctx, http.MethodPut, fmt.Sprintf("/api/v2/users/%s/password", uuidOrMe(userID)), req)
193194
if err != nil {

0 commit comments

Comments
 (0)