Skip to content

feat: set user.must_reset_password to false on change password #14852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion coderd/database/queries/users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ RETURNING *;
UPDATE
users
SET
hashed_password = $2
hashed_password = $2,
must_reset_password = false
WHERE
id = $1;

Expand Down
18 changes: 18 additions & 0 deletions coderd/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,24 @@ func TestUpdateUserPassword(t *testing.T) {
cerr := coderdtest.SDKError(t, err)
require.Equal(t, http.StatusBadRequest, cerr.StatusCode())
})

t.Run("OnUpdateUserPasswordMustResetPasswordIsSetToFalse", func(t *testing.T) {
t.Parallel()

client, db := coderdtest.NewWithDatabase(t, nil)
user := coderdtest.CreateFirstUser(t, client)
ctx := testutil.Context(t, testutil.WaitLong)

err := client.UpdateUserPassword(ctx, "me", codersdk.UpdateUserPasswordRequest{
Password: "MyNewSecurePassword!",
})
require.Nil(t, err)

//nolint:gocritic // Unit test
dbUser, err := db.GetUserByID(dbauthz.AsSystemRestricted(ctx), user.UserID)
require.Nil(t, err)
require.False(t, dbUser.MustResetPassword)
})
}

// TestInitialRoles ensures the starting roles for the first user are correct.
Expand Down
Loading