From 0162d8ad08815b9b833fc651c7e185eab48cbbb2 Mon Sep 17 00:00:00 2001 From: Ruzette Tanyag Date: Wed, 8 Feb 2017 05:00:16 -0500 Subject: Implement GET `/users/username/{username}` endpoint for APIv4 (#5310) * added get user by username endpoint * added get user by username unit test and driver * changed username length to 22 characters max * changed Params to UserName to Username * reorganized get user by username and get user by email formatting in model/client4 --- api4/context.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'api4/context.go') diff --git a/api4/context.go b/api4/context.go index 7ad6f30b4..6a22b4103 100644 --- a/api4/context.go +++ b/api4/context.go @@ -359,6 +359,22 @@ func (c *Context) RequireChannelId() *Context { return c } +func (c *Context) RequireUsername() *Context { + if c.Err != nil { + return c + } + + if len(c.Params.Username) < 3 { + c.SetInvalidUrlParam("username") + } + + if len(c.Params.Username) > 22 { + c.SetInvalidUrlParam("username") + } + + return c +} + func (c *Context) RequireEmail() *Context { if c.Err != nil { return c @@ -371,3 +387,4 @@ func (c *Context) RequireEmail() *Context { return c } + -- cgit v1.2.3-1-g7c22