8000 feat(password): add details field to validate password endpoint · coder/coder@175b4bf · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 175b4bf

Browse files
committed
feat(password): add details field to validate password endpoint
1 parent 36cadeb commit 175b4bf

File tree

8 files changed

+21
-9
lines changed
  • codersdk
  • docs/reference/api
  • site/src/api
  • 8 files changed

    +21
    -9
    lines changed

    coderd/apidoc/docs.go

    Lines changed: 3 additions & 0 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

    coderd/apidoc/swagger.json

    Lines changed: 3 additions & 0 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

    coderd/userauth.go

    Lines changed: 6 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -450,8 +450,9 @@ func (api *API) postChangePasswordWithOneTimePasscode(rw http.ResponseWriter, r
    450450
    // @Router /users/validate-password [post]
    451451
    func (*API) validateUserPassword(rw http.ResponseWriter, r *http.Request) {
    452452
    var (
    453-
    ctx = r.Context()
    454-
    valid = true
    453+
    ctx = r.Context()
    454+
    valid = true
    455+
    details = ""
    455456
    )
    456457

    457458
    var req codersdk.ValidateUserPasswordRequest
    @@ -462,10 +463,12 @@ func (*API) validateUserPassword(rw http.ResponseWriter, r *http.Request) {
    462463
    err := userpassword.Validate(req.Password)
    463464
    if err != nil {
    464465
    valid = false
    466+
    details = err.Error()
    465467
    }
    466468

    467469
    httpapi.Write(ctx, rw, http.StatusOK, codersdk.ValidateUserPasswordResponse{
    468-
    Valid: valid,
    470+
    Valid: valid,
    471+
    Details: details,
    469472
    })
    470473
    }
    471474

    coderd/users_test.go

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1112,8 +1112,6 @@ func TestUpdateUserPassword(t *testing.T) {
    11121112
    // FIXME: Re-enable the tests once real logic changed
    11131113
    // Currently there's no check in code to validate that users have to put the old password
    11141114
    t.Run("MemberCantUpdateOwnPasswordWithoutOldPassword", func(t *testing.T) {
    1115-
    t.Skip()
    1116-
    11171115
    t.Parallel()
    11181116
    client := coderdtest.New(t, nil)
    11191117
    owner := coderdtest.CreateFirstUser(t, client)

    codersdk/users.go

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -181,7 +181,8 @@ type ValidateUserPasswordRequest struct {
    181181
    }
    182182

    183183
    type ValidateUserPasswordResponse struct {
    184-
    Valid bool `json:"valid"`
    184+
    Valid bool `json:"valid"`
    185+
    Details string `json:"details"`
    185186
    }
    186187

    187188
    type UpdateUserAppearanceSettingsRequest struct {

    docs/reference/api/authorization.md

    Lines changed: 1 addition & 0 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

    docs/reference/api/schemas.md

    Lines changed: 5 additions & 3 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

    site/src/api/typesGenerated.ts

    Lines changed: 1 addition & 0 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

    0 commit comments

    Comments
     (0)
    0