Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit96ce751

Browse files
committed
Remove confirm password from the API
1 parentd85092b commit96ce751

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-
ifparams.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
iferr!=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
funcTestUpdateUserPassword(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-
varapiErr*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
typeUpdateUserPasswordRequeststruct {
76-
Passwordstring`json:"password" validate:"required"`
77-
ConfirmPasswordstring`json:"confirm_new_password" validate:"required"`
76+
Passwordstring`json:"password" validate:"required"`
7877
}
7978

8079
typeUpdateRolesstruct {

‎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
readonlyprivate_key:string
1313
}
1414

15-
// From codersdk/users.go:110:6
15+
// From codersdk/users.go:109:6
1616
exportinterfaceAuthMethods{
1717
readonlypassword:boolean
1818
readonlygithub:boolean
@@ -44,7 +44,7 @@ export interface CreateFirstUserResponse {
4444
readonlyorganization_id:string
4545
}
4646

47-
// From codersdk/users.go:105:6
47+
// From codersdk/users.go:104:6
4848
exportinterfaceCreateOrganizationRequest{
4949
readonlyname:string
5050
}
@@ -101,7 +101,7 @@ export interface CreateWorkspaceRequest {
101101
readonlyparameter_values:CreateParameterRequest[]
102102
}
103103

104-
// From codersdk/users.go:101:6
104+
// From codersdk/users.go:100:6
105105
exportinterfaceGenerateAPIKeyResponse{
106106
readonlykey:string
107107
}
@@ -119,13 +119,13 @@ export interface GoogleInstanceIdentityToken {
119119
readonlyjson_web_token:string
120120
}
121121

122-
// From codersdk/users.go:90:6
122+
// From codersdk/users.go:89:6
123123
exportinterfaceLoginWithPasswordRequest{
124124
readonlyemail:string
125125
readonlypassword:string
126126
}
127127

128-
// From codersdk/users.go:96:6
128+
// From codersdk/users.go:95:6
129129
exportinterfaceLoginWithPasswordResponse{
130130
readonlysession_token:string
131131
}
@@ -255,15 +255,14 @@ export interface UpdateActiveTemplateVersion {
255255
readonlyid:string
256256
}
257257

258-
// From codersdk/users.go:80:6
258+
// From codersdk/users.go:79:6
259259
exportinterfaceUpdateRoles{
260260
readonlyroles:string[]
261261
}
262262

263263
// From codersdk/users.go:75:6
264264
exportinterfaceUpdateUserPasswordRequest{
265265
readonlypassword:string
266-
readonlyconfirm_new_password:string
267266
}
268267

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

300-
// From codersdk/users.go:84:6
299+
// From codersdk/users.go:83:6
301300
exportinterfaceUserRoles{
302301
readonlyroles:string[]
303302
readonlyorganization_roles:Record<string,string[]>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp