summaryrefslogtreecommitdiffstats
path: root/api4/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'api4/context.go')
-rw-r--r--api4/context.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/api4/context.go b/api4/context.go
index 61c318266..d72b3593d 100644
--- a/api4/context.go
+++ b/api4/context.go
@@ -239,6 +239,11 @@ func (c *Context) IsSystemAdmin() bool {
}
func (c *Context) SessionRequired() {
+ if !*utils.Cfg.ServiceSettings.EnableUserAccessTokens && c.Session.Props[model.SESSION_PROP_TYPE] == model.SESSION_TYPE_USER_ACCESS_TOKEN {
+ c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "UserAccessToken", http.StatusUnauthorized)
+ return
+ }
+
if len(c.Session.UserId) == 0 {
c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "UserRequired", http.StatusUnauthorized)
return
@@ -361,6 +366,17 @@ func (c *Context) RequireInviteId() *Context {
return c
}
+func (c *Context) RequireTokenId() *Context {
+ if c.Err != nil {
+ return c
+ }
+
+ if len(c.Params.TokenId) != 26 {
+ c.SetInvalidUrlParam("token_id")
+ }
+ return c
+}
+
func (c *Context) RequireChannelId() *Context {
if c.Err != nil {
return c