mirror of https://github.com/coder/coder.git
chore: do not allow resetting password of non password users (#9003)
This commit is contained in:
parent
919f5c6fe9
commit
f334b66178
|
@ -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{
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -205,7 +205,7 @@ export const UsersTableBody: FC<
|
|||
{
|
||||
label: t("resetPasswordMenuItem"),
|
||||
onClick: onResetUserPassword,
|
||||
disabled: false,
|
||||
disabled: user.login_type !== "password",
|
||||
},
|
||||
{
|
||||
label: t("listWorkspacesMenuItem"),
|
||||
|
|
Loading…
Reference in New Issue