From d2ddf40f56191c1770c3ca93d747a7f1b749f26c Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Thu, 5 May 2016 16:35:03 -0400 Subject: PLT-2600/PLT-2770 Added Get Public Link modal and added new API for public file links (#2892) * Switched public file links to use a GetLinkModal * Separated getFile and the new getPublicFile api calls --- api/context.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'api/context.go') diff --git a/api/context.go b/api/context.go index 8bbd5a1d2..03d0046be 100644 --- a/api/context.go +++ b/api/context.go @@ -80,6 +80,10 @@ func ApiUserRequiredTrustRequester(h func(*Context, http.ResponseWriter, *http.R return &handler{h, true, false, true, true, false, true} } +func ApiAppHandlerTrustRequesterIndependent(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler { + return &handler{h, false, false, true, false, true, true} +} + type handler struct { handleFunc func(*Context, http.ResponseWriter, *http.Request) requireUser bool @@ -187,7 +191,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { c.SystemAdminRequired() } - if c.Err == nil && len(c.TeamId) > 0 { + if c.Err == nil && len(c.TeamId) > 0 && !h.isTeamIndependent { c.HasPermissionsToTeam(c.TeamId, "TeamRoute") } @@ -389,8 +393,13 @@ func (c *Context) RemoveSessionCookie(w http.ResponseWriter, r *http.Request) { } func (c *Context) SetInvalidParam(where string, name string) { - c.Err = model.NewLocAppError(where, "api.context.invalid_param.app_error", map[string]interface{}{"Name": name}, "") - c.Err.StatusCode = http.StatusBadRequest + c.Err = NewInvalidParamError(where, name) +} + +func NewInvalidParamError(where string, name string) *model.AppError { + err := model.NewLocAppError(where, "api.context.invalid_param.app_error", map[string]interface{}{"Name": name}, "") + err.StatusCode = http.StatusBadRequest + return err } func (c *Context) SetUnknownError(where string, details string) { -- cgit v1.2.3-1-g7c22