Skip to content

Commit f334b66

Browse files
authored
chore: do not allow resetting password of non password users (coder#9003)
1 parent 919f5c6 commit f334b66

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

coderd/users.go

+7
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,13 @@ func (api *API) putUserPassword(rw http.ResponseWriter, r *http.Request) {
733733
return
734734
}
735735

736+
if user.LoginType != database.LoginTypePassword {
737+
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
738+
Message: "Users without password login type cannot change their password.",
739+
})
740+
return
741+
}
742+
736743
err := userpassword.Validate(params.Password)
737744
if err != nil {
738745
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{

site/src/components/UsersTable/UsersTable.stories.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ Editable.args = {
4242
roles: [],
4343
status: "suspended",
4444
},
45+
{
46+
...MockUser,
47+
username: "OIDC User",
48+
email: "oidc.user@coder.com",
49+
roles: [],
50+
status: "active",
51+
login_type: "oidc",
52+
},
4553
],
4654
roles: MockAssignableSiteRoles,
4755
canEditUsers: true,

site/src/components/UsersTable/UsersTableBody.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export const UsersTableBody: FC<
205205
{
206206
label: t("resetPasswordMenuItem"),
207207
onClick: onResetUserPassword,
208-
disabled: false,
208+
disabled: user.login_type !== "password",
209209
},
210210
{
211211
label: t("listWorkspacesMenuItem"),

0 commit comments

Comments
 (0)