Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d85092b

Browse files
committed
Update update password request params
1 parent 69af903 commit d85092b

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

coderd/users.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ func (api *api) putUserPassword(rw http.ResponseWriter, r *http.Request) {
369369
}
370370

371371
// Check if the new password and the confirmation match
372-
if params.NewPassword != params.ConfirmNewPassword {
372+
if params.Password != params.ConfirmPassword {
373373
requestErrors := []httpapi.Error{
374374
{
375375
Field: "confirm_new_password",
@@ -384,7 +384,7 @@ func (api *api) putUserPassword(rw http.ResponseWriter, r *http.Request) {
384384
}
385385

386386
// Hash password and update it in the database
387-
hashedPassword, err := userpassword.Hash(params.NewPassword)
387+
hashedPassword, err := userpassword.Hash(params.Password)
388388
if err != nil {
389389
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
390390
Message: fmt.Sprintf("hash password: %s", err.Error()),

coderd/users_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,8 @@ func TestUpdateUserPassword(t *testing.T) {
295295
client := coderdtest.New(t, nil)
296296
coderdtest.CreateFirstUser(t, client)
297297
err := client.UpdateUserPassword(context.Background(), codersdk.Me, codersdk.UpdateUserPasswordRequest{
298-
Password: coderdtest.FirstUserParams.Password,
299-
NewPassword: "newpassword",
300-
ConfirmNewPassword: "wrongconfirmation",
298+
Password: "newpassword",
299+
ConfirmPassword: "wrongconfirmation",
301300
})
302301
var apiErr *codersdk.Error
303302
require.ErrorAs(t, err, &apiErr)
@@ -309,9 +308,8 @@ func TestUpdateUserPassword(t *testing.T) {
309308
client := coderdtest.New(t, nil)
310309
coderdtest.CreateFirstUser(t, client)
311310
err := client.UpdateUserPassword(context.Background(), codersdk.Me, codersdk.UpdateUserPasswordRequest{
312-
Password: coderdtest.FirstUserParams.Password,
313-
NewPassword: "newpassword",
314-
ConfirmNewPassword: "newpassword",
311+
Password: "newpassword",
312+
ConfirmPassword: "newpassword",
315313
})
316314
require.NoError(t, err, "update password request should be successful")
317315

codersdk/users.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ type UpdateUserProfileRequest struct {
7373
}
7474

7575
type UpdateUserPasswordRequest struct {
76-
Password string `json:"password" validate:"required"`
77-
NewPassword string `json:"new_password" validate:"required"`
78-
ConfirmNewPassword string `json:"confirm_new_password" validate:"required"`
76+
Password string `json:"password" validate:"required"`
77+
ConfirmPassword string `json:"confirm_new_password" validate:"required"`
7978
}
8079

8180
type UpdateRoles struct {

site/src/api/typesGenerated.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface AgentGitSSHKey {
1212
readonly private_key: string
1313
}
1414

15-
// From codersdk/users.go:111:6
15+
// From codersdk/users.go:110:6
1616
export interface AuthMethods {
1717
readonly password: boolean
1818
readonly github: boolean
@@ -44,7 +44,7 @@ export interface CreateFirstUserResponse {
4444
readonly organization_id: string
4545
}
4646

47-
// From codersdk/users.go:106:6
47+
// From codersdk/users.go:105:6
4848
export interface CreateOrganizationRequest {
4949
readonly name: string
5050
}
@@ -101,7 +101,7 @@ export interface CreateWorkspaceRequest {
101101
readonly parameter_values: CreateParameterRequest[]
102102
}
103103

104-
// From codersdk/users.go:102:6
104+
// From codersdk/users.go:101:6
105105
export interface GenerateAPIKeyResponse {
106106
readonly key: string
107107
}
@@ -119,13 +119,13 @@ export interface GoogleInstanceIdentityToken {
119119
readonly json_web_token: string
120120
}
121121

122-
// From codersdk/users.go:91:6
122+
// From codersdk/users.go:90:6
123123
export interface LoginWithPasswordRequest {
124124
readonly email: string
125125
readonly password: string
126126
}
127127

128-
// From codersdk/users.go:97:6
128+
// From codersdk/users.go:96:6
129129
export interface LoginWithPasswordResponse {
130130
readonly session_token: string
131131
}
@@ -255,15 +255,14 @@ export interface UpdateActiveTemplateVersion {
255255
readonly id: string
256256
}
257257

258-
// From codersdk/users.go:81:6
258+
// From codersdk/users.go:80:6
259259
export interface UpdateRoles {
260260
readonly roles: string[]
261261
}
262262

263263
// From codersdk/users.go:75:6
264264
export interface UpdateUserPasswordRequest {
265265
readonly password: string
266-
readonly new_password: string
267266
readonly confirm_new_password: string
268267
}
269268

@@ -298,7 +297,7 @@ export interface User {
298297
readonly organization_ids: string[]
299298
}
300299

301-
// From codersdk/users.go:85:6
300+
// From codersdk/users.go:84:6
302301
export interface UserRoles {
303302
readonly roles: string[]
304303
readonly organization_roles: Record<string, string[]>

0 commit comments

Comments
 (0)