diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-02-07 09:35:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-07 09:35:58 -0800 |
commit | 9dc76c18231f158ab71dfcfae2f1659a4f2a5396 (patch) | |
tree | 57a46a30e52e9f955f4d74d93fc6153640fbecc2 /model | |
parent | ba18374bd1b2644e577247204fad17dd52913b9b (diff) | |
download | chat-9dc76c18231f158ab71dfcfae2f1659a4f2a5396.tar.gz chat-9dc76c18231f158ab71dfcfae2f1659a4f2a5396.tar.bz2 chat-9dc76c18231f158ab71dfcfae2f1659a4f2a5396.zip |
Implement PUT /users/{user_id}/password endpoint for APIv4 (#5243)
Diffstat (limited to 'model')
-rw-r--r-- | model/client4.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go index 88082869e..41963edba 100644 --- a/model/client4.go +++ b/model/client4.go @@ -292,6 +292,17 @@ func (c *Client4) UpdateUser(user *User) (*User, *Response) { } } +// UpdateUserPassword updates a user's password. Must be logged in as the user or be a system administrator. +func (c *Client4) UpdateUserPassword(userId, currentPassword, newPassword string) (bool, *Response) { + requestBody := map[string]string{"current_password": currentPassword, "new_password": newPassword} + if r, err := c.DoApiPut(c.GetUserRoute(userId)+"/password", MapToJson(requestBody)); err != nil { + return false, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return CheckStatusOK(r), BuildResponse(r) + } +} + // UpdateUserRoles updates a user's roles in the system. A user can have "system_user" and "system_admin" roles. func (c *Client4) UpdateUserRoles(userId, roles string) (bool, *Response) { requestBody := map[string]string{"roles": roles} |