Skip to content

chore: do not allow resetting password of non password users #9003

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

Merged
merged 2 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
chore: do not allow resetting password of non password users
  • Loading branch information
Emyrk committed Aug 9, 2023
commit 2043514aa9beeedb138aef6e2d89329fa812a370
7 changes: 7 additions & 0 deletions coderd/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,13 @@ func (api *API) putUserPassword(rw http.ResponseWriter, r *http.Request) {
return
}

if user.LoginType != database.LoginTypePassword {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "Users without password login type cannot change their password.",
})
return
}

err := userpassword.Validate(params.Password)
if err != nil {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Expand Down
8 changes: 8 additions & 0 deletions site/src/components/UsersTable/UsersTable.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ Editable.args = {
roles: [],
status: "suspended",
},
{
...MockUser,
username: "OIDC User",
email: "oidc.user@coder.com",
roles: [],
status: "active",
login_type: "oidc",
},
],
roles: MockAssignableSiteRoles,
canEditUsers: true,
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/UsersTable/UsersTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export const UsersTableBody: FC<
{
label: t("resetPasswordMenuItem"),
onClick: onResetUserPassword,
disabled: false,
disabled: user.login_type !== "password",
},
{
label: t("listWorkspacesMenuItem"),
Expand Down