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

This commit is contained in:
Steven Masley 2023-08-09 13:56:13 -05:00 committed by GitHub
parent 919f5c6fe9
commit f334b66178
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -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{

View File

@ -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,

View File

@ -205,7 +205,7 @@ export const UsersTableBody: FC<
{
label: t("resetPasswordMenuItem"),
onClick: onResetUserPassword,
disabled: false,
disabled: user.login_type !== "password",
},
{
label: t("listWorkspacesMenuItem"),