summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-13 08:29:56 -0400
committerGeorge Goldberg <george@gberg.me>2017-03-13 12:29:56 +0000
commit8b0eedbbcd47ba09142c72a71969840aa6e121d2 (patch)
tree30c073e01dfbe40065aa2bb7900339362a57a07f /model
parent1860d05d623b6fd7670121a7e2391605d1281b27 (diff)
downloadchat-8b0eedbbcd47ba09142c72a71969840aa6e121d2.tar.gz
chat-8b0eedbbcd47ba09142c72a71969840aa6e121d2.tar.bz2
chat-8b0eedbbcd47ba09142c72a71969840aa6e121d2.zip
Implement PUT /users/{user_id}/mfa endpoint for APIv4 (#5743)
Diffstat (limited to 'model')
-rw-r--r--model/client4.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index 9a1d6e1cf..70466ec59 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -457,6 +457,22 @@ func (c *Client4) PatchUser(userId string, patch *UserPatch) (*User, *Response)
}
}
+// UpdateUserMfa activates multi-factor authentication for a user if activate
+// is true and a valid code is provided. If activate is false, then code is not
+// required and multi-factor authentication is disabled for the user.
+func (c *Client4) UpdateUserMfa(userId, code string, activate bool) (bool, *Response) {
+ requestBody := make(map[string]interface{})
+ requestBody["activate"] = activate
+ requestBody["code"] = code
+
+ if r, err := c.DoApiPut(c.GetUserRoute(userId)+"/mfa", StringInterfaceToJson(requestBody)); err != nil {
+ return false, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return CheckStatusOK(r), BuildResponse(r)
+ }
+}
+
// 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}