summaryrefslogtreecommitdiffstats
path: root/model/client4.go
diff options
context:
space:
mode:
authorNick Frazier <nrflaw@gmail.com>2017-10-19 08:10:29 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-10-19 08:10:29 -0400
commit7fa4913f902457dadb1a4806ce194eb122dbc090 (patch)
treeea340ad55f6dfa1e6ee647e0a87af69ac406e25d /model/client4.go
parent8e19ba029f889519d93cf272960dce858971106c (diff)
downloadchat-7fa4913f902457dadb1a4806ce194eb122dbc090.tar.gz
chat-7fa4913f902457dadb1a4806ce194eb122dbc090.tar.bz2
chat-7fa4913f902457dadb1a4806ce194eb122dbc090.zip
[PLT-7794] Add user access token enable/disable endpoints (#7630)
* Add column to UserAccessTokens table * PLT-7794 Add user access token enable/disable endpoints * replaced eliminated global variable * updates to user_access_token_store and upgrade.go * style fix and cleanup
Diffstat (limited to 'model/client4.go')
-rw-r--r--model/client4.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index 5703c4143..dc5a25bec 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -1065,6 +1065,32 @@ func (c *Client4) RevokeUserAccessToken(tokenId string) (bool, *Response) {
}
}
+// DisableUserAccessToken will disable a user access token by id. Must have the
+// 'revoke_user_access_token' permission and if disabling for another user, must have the
+// 'edit_other_users' permission.
+func (c *Client4) DisableUserAccessToken(tokenId string) (bool, *Response) {
+ requestBody := map[string]string{"token_id": tokenId}
+ if r, err := c.DoApiPost(c.GetUsersRoute()+"/tokens/disable", MapToJson(requestBody)); err != nil {
+ return false, BuildErrorResponse(r, err)
+ } else {
+ defer closeBody(r)
+ return CheckStatusOK(r), BuildResponse(r)
+ }
+}
+
+// EnableUserAccessToken will enable a user access token by id. Must have the
+// 'create_user_access_token' permission and if enabling for another user, must have the
+// 'edit_other_users' permission.
+func (c *Client4) EnableUserAccessToken(tokenId string) (bool, *Response) {
+ requestBody := map[string]string{"token_id": tokenId}
+ if r, err := c.DoApiPost(c.GetUsersRoute()+"/tokens/enable", MapToJson(requestBody)); err != nil {
+ return false, BuildErrorResponse(r, 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.