summaryrefslogtreecommitdiffstats
path: root/api/context.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-09-30 09:34:05 -0400
committerChristopher Speller <crspeller@gmail.com>2015-09-30 14:26:37 -0400
commit89b77cc72ffd9dec6242f66277a4aeffe6fb737b (patch)
tree5af762b4d690e10150350b583ff8c20881cc6880 /api/context.go
parent0a9d93974f7f5ca4f8013d5f79faacc3446e7018 (diff)
downloadchat-89b77cc72ffd9dec6242f66277a4aeffe6fb737b.tar.gz
chat-89b77cc72ffd9dec6242f66277a4aeffe6fb737b.tar.bz2
chat-89b77cc72ffd9dec6242f66277a4aeffe6fb737b.zip
Fixing permissions for system admin. Fixes slack import for system admins.
Diffstat (limited to 'api/context.go')
-rw-r--r--api/context.go25
1 files changed, 11 insertions, 14 deletions
diff --git a/api/context.go b/api/context.go
index d90fbd9ee..0cc5a2b53 100644
--- a/api/context.go
+++ b/api/context.go
@@ -292,14 +292,6 @@ func (c *Context) HasPermissionsToChannel(sc store.StoreChannel, where string) b
return true
}
-func (c *Context) IsSystemAdmin() bool {
- // TODO XXX FIXME && IsPrivateIpAddress(c.IpAddress)
- if model.IsInRole(c.Session.Roles, model.ROLE_SYSTEM_ADMIN) {
- return true
- }
- return false
-}
-
func (c *Context) HasSystemAdminPermissions(where string) bool {
if c.IsSystemAdmin() {
return true
@@ -310,14 +302,19 @@ func (c *Context) HasSystemAdminPermissions(where string) bool {
return false
}
+func (c *Context) IsSystemAdmin() bool {
+ // TODO XXX FIXME && IsPrivateIpAddress(c.IpAddress)
+ if model.IsInRole(c.Session.Roles, model.ROLE_SYSTEM_ADMIN) {
+ return true
+ }
+ return false
+}
+
func (c *Context) IsTeamAdmin(userId string) bool {
- if uresult := <-Srv.Store.User().Get(userId); uresult.Err != nil {
- c.Err = uresult.Err
- return false
- } else {
- user := uresult.Data.(*model.User)
- return model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) && user.TeamId == c.Session.TeamId
+ if model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) || c.IsSystemAdmin() {
+ return true
}
+ return false
}
func (c *Context) RemoveSessionCookie(w http.ResponseWriter) {