summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-24 16:42:05 -0400
committerCorey Hulen <corey@hulen.com>2017-03-24 13:42:05 -0700
commit11b7aa859c4b5108207b1395a91ddbc988ccf00b (patch)
tree30d93a5ad563dbf6bea17bdcfb9a9a24abbeb4bf /model
parenta2f78d01bd4d105da374c46bd40c2a585bddd536 (diff)
downloadchat-11b7aa859c4b5108207b1395a91ddbc988ccf00b.tar.gz
chat-11b7aa859c4b5108207b1395a91ddbc988ccf00b.tar.bz2
chat-11b7aa859c4b5108207b1395a91ddbc988ccf00b.zip
Implement POST /users/email/verify/send endpoint for APIv4 (#5825)
Diffstat (limited to 'model')
-rw-r--r--model/client4.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/model/client4.go b/model/client4.go
index 3aef5019c..b269f2f34 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -645,10 +645,23 @@ func (c *Client4) GetUserAudits(userId string, page int, perPage int, etag strin
}
}
-// Verify user email user id and hash strings.
+// VerifyUserEmail will verify a user's email using user id and hash strings.
func (c *Client4) VerifyUserEmail(userId, hashId string) (bool, *Response) {
- requestBody := map[string]string{"uid": userId, "hid": hashId}
- if r, err := c.DoApiPost(c.GetUserRoute(userId)+"/email/verify", MapToJson(requestBody)); err != nil {
+ requestBody := map[string]string{"user_id": userId, "hash_id": hashId}
+ if r, err := c.DoApiPost(c.GetUsersRoute()+"/email/verify", MapToJson(requestBody)); err != nil {
+ return false, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return CheckStatusOK(r), BuildResponse(r)
+ }
+}
+
+// SendVerificationEmail will send an email to the user with the provided email address, if
+// that user exists. The email will contain a link that can be used to verify the user's
+// email address.
+func (c *Client4) SendVerificationEmail(email string) (bool, *Response) {
+ requestBody := map[string]string{"email": email}
+ if r, err := c.DoApiPost(c.GetUsersRoute()+"/email/verify/send", MapToJson(requestBody)); err != nil {
return false, &Response{StatusCode: r.StatusCode, Error: err}
} else {
defer closeBody(r)