From d31b3e413a71607f6f9593f414892cace955fb1a Mon Sep 17 00:00:00 2001 From: nickago Date: Thu, 16 Jul 2015 13:40:18 -0700 Subject: Moved admin checking into seperate function --- api/context.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'api/context.go') 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) -- cgit v1.2.3-1-g7c22