summaryrefslogtreecommitdiffstats
path: root/api/context.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-05-05 16:35:03 -0400
committerChristopher Speller <crspeller@gmail.com>2016-05-05 16:35:03 -0400
commitd2ddf40f56191c1770c3ca93d747a7f1b749f26c (patch)
tree9cd5d9ac9fc5b9da21fba8df9990c5f927801272 /api/context.go
parent696ffb4745bec6306f88c5693b8ded89a47f5de7 (diff)
downloadchat-d2ddf40f56191c1770c3ca93d747a7f1b749f26c.tar.gz
chat-d2ddf40f56191c1770c3ca93d747a7f1b749f26c.tar.bz2
chat-d2ddf40f56191c1770c3ca93d747a7f1b749f26c.zip
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
Diffstat (limited to 'api/context.go')
-rw-r--r--api/context.go15
1 files changed, 12 insertions, 3 deletions
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) {