From 4ce37aad044f5b5caca48d5b68e109d87c7d1648 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sun, 15 Jun 2014 21:29:53 -0400 Subject: [PATCH] Change groupfinder to use the groups table. --- xonstat/security.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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 -- 2.39.2