diff options
author | nickago <ngonella@calpoly.edu> | 2015-07-16 13:40:18 -0700 |
---|---|---|
committer | nickago <ngonella@calpoly.edu> | 2015-07-16 13:40:18 -0700 |
commit | d31b3e413a71607f6f9593f414892cace955fb1a (patch) | |
tree | 8d4b069aa786879e009df8496d4660c1149b1f5d /api/context.go | |
parent | cb2bff28ee7a43b3d3c52d3c448d3f15d12830ba (diff) | |
download | chat-d31b3e413a71607f6f9593f414892cace955fb1a.tar.gz chat-d31b3e413a71607f6f9593f414892cace955fb1a.tar.bz2 chat-d31b3e413a71607f6f9593f414892cace955fb1a.zip |
Moved admin checking into seperate function
Diffstat (limited to 'api/context.go')
-rw-r--r-- | api/context.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/api/context.go b/api/context.go index bea0fbeff..0c9dee5c3 100644 --- a/api/context.go +++ b/api/context.go @@ -265,6 +265,16 @@ func (c *Context) IsSystemAdmin() bool { return false } +func (c *Context) IsTeamAdmin() bool { + if uresult := <-Srv.Store.User().Get(c.Session.UserId); uresult.Err != nil { + c.Err = uresult.Err + return false + } else { + user := uresult.Data.(*model.User) + return strings.Contains(user.Roles, model.ROLE_ADMIN) && user.TeamId == c.Session.TeamId + } +} + func (c *Context) RemoveSessionCookie(w http.ResponseWriter) { sessionCache.Remove(c.Session.Id) |