Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 4481be3

Browse files
committed
feat: enable password changes in coder-sdk
This allows modification of passwords and the temporary password flag for users managed by the built-in authentication provider.
1 parent 3253e56 commit 4481be3

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

coder-sdk/users.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (c *DefaultClient) UserByEmail(ctx context.Context, email string) (*User, e
9999
// UpdateUserReq defines a modification to the user, updating the
100100
// value of all non-nil values.
101101
type UpdateUserReq struct {
102-
// TODO(@cmoog) add update password option
102+
*UserPasswordSettings
103103
Revoked *bool `json:"revoked,omitempty"`
104104
Roles *[]Role `json:"roles,omitempty"`
105105
LoginType *LoginType `json:"login_type,omitempty"`
@@ -109,6 +109,27 @@ type UpdateUserReq struct {
109109
DotfilesGitURL *string `json:"dotfiles_git_uri,omitempty"`
110110
}
111111

112+
// UserPasswordSettings allows modification of the user's password
113+
// settings.
114+
//
115+
// These settings are only applicable to users managed using the
116+
// built-in authentication provider; users authenticating using
117+
// OAuth must change their password through the identity provider
118+
// instead.
119+
type UserPasswordSettings struct {
120+
// OldPassword is the account's current password.
121+
OldPassword string `json:"old_password,omitempty"`
122+
123+
// Password is the new password, which may be a temporary password.
124+
Password string `json:"password,omitempty"`
125+
126+
// Temporary indicates that API access should be restricted to the
127+
// password change API and a few other APIs. If set to true, Coder
128+
// will prompt the user to change their password upon their next
129+
// login through the web interface.
130+
Temporary bool `json:"temporary_password,omitempty"`
131+
}
132+
112133
// UpdateUser applyes the partial update to the given user.
113134
func (c *DefaultClient) UpdateUser(ctx context.Context, userID string, req UpdateUserReq) error {
114135
return c.requestBody(ctx, http.MethodPatch, "/api/v0/users/"+userID, req, nil)

0 commit comments

Comments
 (0)