summaryrefslogtreecommitdiffstats
path: root/api4/context.go
diff options
context:
space:
mode:
authorRuzette Tanyag <ruzette@users.noreply.github.com>2017-02-07 11:54:07 -0500
committerChristopher Speller <crspeller@gmail.com>2017-02-07 11:54:07 -0500
commitd91fea65188a51dd41976cad47f9c8ebacd75a04 (patch)
tree792f8563d04957c1ddf56a731821051c8466eba7 /api4/context.go
parent5cc30fa06149e1291deed6f53de53ecf25600d2c (diff)
downloadchat-d91fea65188a51dd41976cad47f9c8ebacd75a04.tar.gz
chat-d91fea65188a51dd41976cad47f9c8ebacd75a04.tar.bz2
chat-d91fea65188a51dd41976cad47f9c8ebacd75a04.zip
Implement GET `/users/email/{email}` endpoint for APIv4 (#5309)
* added get user by email endpoint for APIv4 * added get user by email endpoint unit test and driver * removed the appended return of user ids on logout * Added RequireEmail to validate user email. Also updated the get user by email endpoint and unit test
Diffstat (limited to 'api4/context.go')
-rw-r--r--api4/context.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/api4/context.go b/api4/context.go
index 1a3011795..7ad6f30b4 100644
--- a/api4/context.go
+++ b/api4/context.go
@@ -358,3 +358,16 @@ func (c *Context) RequireChannelId() *Context {
}
return c
}
+
+func (c *Context) RequireEmail() *Context {
+ if c.Err != nil {
+ return c
+ }
+
+ pos := strings.Index(c.Params.Email, "@")
+ if pos < 0 {
+ c.SetInvalidUrlParam("email")
+ }
+
+ return c
+}