summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-01 16:13:16 -0500
committerChristopher Speller <crspeller@gmail.com>2017-02-01 16:13:16 -0500
commit36f43edba3481a19476943942bff1ab53cc14e0f (patch)
tree4f2925a492cb594e6c80a7f569395528139307ce /model
parent187aff9fa8bd7616b5a93aefaa2e9166d5d3d4ab (diff)
downloadchat-36f43edba3481a19476943942bff1ab53cc14e0f.tar.gz
chat-36f43edba3481a19476943942bff1ab53cc14e0f.tar.bz2
chat-36f43edba3481a19476943942bff1ab53cc14e0f.zip
Implement PUT /users/{user_id}/roles endpoint for APIv4 (#5238)
Diffstat (limited to 'model')
-rw-r--r--model/client4.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index 6752a4b60..f0adfd382 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -212,6 +212,17 @@ func (c *Client4) UpdateUser(user *User) (*User, *Response) {
}
}
+// 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}
+ if r, err := c.DoApiPut(c.GetUserRoute(userId)+"/roles", MapToJson(requestBody)); err != nil {
+ return false, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return CheckStatusOK(r), BuildResponse(r)
+ }
+}
+
// Team Section
// CreateTeam creates a team in the system based on the provided team struct.