From be9624e2adce7c95039e62fc4ee22538d7fa2d2f Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Thu, 20 Apr 2017 09:55:02 -0400 Subject: Implement v4 endpoints for OAuth (#6040) * Implement POST /oauth/apps endpoint for APIv4 * Implement GET /oauth/apps endpoint for APIv4 * Implement GET /oauth/apps/{app_id} and /oauth/apps/{app_id}/info endpoints for APIv4 * Refactor API version independent oauth endpoints * Implement DELETE /oauth/apps/{app_id} endpoint for APIv4 * Implement /oauth/apps/{app_id}/regen_secret endpoint for APIv4 * Implement GET /user/{user_id}/oauth/apps/authorized endpoint for APIv4 * Implement POST /oauth/deauthorize endpoint --- api4/context.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'api4/context.go') diff --git a/api4/context.go b/api4/context.go index 847a8d55f..f492f2b99 100644 --- a/api4/context.go +++ b/api4/context.go @@ -382,6 +382,17 @@ func (c *Context) RequirePostId() *Context { return c } +func (c *Context) RequireAppId() *Context { + if c.Err != nil { + return c + } + + if len(c.Params.AppId) != 26 { + c.SetInvalidUrlParam("app_id") + } + return c +} + func (c *Context) RequireFileId() *Context { if c.Err != nil { return c @@ -464,6 +475,18 @@ func (c *Context) RequireCategory() *Context { return c } +func (c *Context) RequireService() *Context { + if c.Err != nil { + return c + } + + if len(c.Params.Service) == 0 { + c.SetInvalidUrlParam("service") + } + + return c +} + func (c *Context) RequirePreferenceName() *Context { if c.Err != nil { return c -- cgit v1.2.3-1-g7c22