From: Ant Zucaro Date: Mon, 16 Jun 2014 01:29:53 +0000 (-0400) Subject: Change groupfinder to use the groups table. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4ce37aad044f5b5caca48d5b68e109d87c7d1648;p=xonotic%2Fxonstat.git Change groupfinder to use the groups table. --- diff --git a/xonstat/security.py b/xonstat/security.py index b942de1..47828a4 100644 --- a/xonstat/security.py +++ b/xonstat/security.py @@ -1,4 +1,8 @@ +import logging from pyramid.security import Allow, Everyone +from xonstat.models import DBSession, Player, PlayerGroups + +log = logging.getLogger(__name__) USERS = { 'admin':'admin', @@ -20,8 +24,16 @@ class ACLFactory(object): def groupfinder(userid, request): - print('userid is %s' % userid) - if userid in USERS: - return GROUPS.get(userid, []) - else: - return [] + groups = [] + try: + groups_q = DBSession.query(PlayerGroups.group_name).\ + filter(Player.email_addr == userid).all() + + for g in groups_q: + groups.append(g.group_name) + except: + pass + + log.debug("Found the following groups for %s: %s" % (userid, groups)) + + return groups