Skip to content

Commit 96ce751

Browse files
committed
Remove confirm password from the API
1 parent d85092b commit 96ce751

File tree

4 files changed

+9
-41
lines changed

4 files changed

+9
-41
lines changed

coderd/users.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -368,22 +368,6 @@ func (api *api) putUserPassword(rw http.ResponseWriter, r *http.Request) {
368368
return
369369
}
370370

371-
// Check if the new password and the confirmation match
372-
if params.Password != params.ConfirmPassword {
373-
requestErrors := []httpapi.Error{
374-
{
375-
Field: "confirm_new_password",
376-
Detail: "The value does not match the new password",
377-
},
378-
}
379-
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
380-
Message: fmt.Sprintf("The new password and the new password confirmation don't match"),
381-
Errors: requestErrors,
382-
})
383-
return
384-
}
385-
386-
// Hash password and update it in the database
387371
hashedPassword, err := userpassword.Hash(params.Password)
388372
if err != nil {
389373
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{

coderd/users_test.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -290,26 +290,12 @@ func TestUpdateUserProfile(t *testing.T) {
290290
func TestUpdateUserPassword(t *testing.T) {
291291
t.Parallel()
292292

293-
t.Run("DifferentPasswordConfirmation", func(t *testing.T) {
294-
t.Parallel()
295-
client := coderdtest.New(t, nil)
296-
coderdtest.CreateFirstUser(t, client)
297-
err := client.UpdateUserPassword(context.Background(), codersdk.Me, codersdk.UpdateUserPasswordRequest{
298-
Password: "newpassword",
299-
ConfirmPassword: "wrongconfirmation",
300-
})
301-
var apiErr *codersdk.Error
302-
require.ErrorAs(t, err, &apiErr)
303-
require.Equal(t, http.StatusBadRequest, apiErr.StatusCode())
304-
})
305-
306293
t.Run("Success", func(t *testing.T) {
307294
t.Parallel()
308295
client := coderdtest.New(t, nil)
309296
coderdtest.CreateFirstUser(t, client)
310297
err := client.UpdateUserPassword(context.Background(), codersdk.Me, codersdk.UpdateUserPasswordRequest{
311-
Password: "newpassword",
312-
ConfirmPassword: "newpassword",
298+
Password: "newpassword",
313299
})
314300
require.NoError(t, err, "update password request should be successful")
315301

codersdk/users.go

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

7575
type UpdateUserPasswordRequest struct {
76-
Password string `json:"password" validate:"required"`
77-
ConfirmPassword string `json:"confirm_new_password" validate:"required"`
76+
Password string `json:"password" validate:"required"`
7877
}
7978

8079
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:110:6
15+
// From codersdk/users.go:109: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:105:6
47+
// From codersdk/users.go:104: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:101:6
104+
// From codersdk/users.go:100: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:90:6
122+
// From codersdk/users.go:89:6
123123
export interface LoginWithPasswordRequest {
124124
readonly email: string
125125
readonly password: string
126126
}
127127

128-
// From codersdk/users.go:96:6
128+
// From codersdk/users.go:95: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:80:6
258+
// From codersdk/users.go:79: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 confirm_new_password: string
267266
}
268267

269268
// From codersdk/users.go:70:6
@@ -297,7 +296,7 @@ export interface User {
297296
readonly organization_ids: string[]
298297
}
299298

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

0 commit comments

Comments
 (0)