]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Change groupfinder to use the groups table.
authorAnt Zucaro <azucaro@gmail.com>
Mon, 16 Jun 2014 01:29:53 +0000 (21:29 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Mon, 16 Jun 2014 01:29:53 +0000 (21:29 -0400)
xonstat/security.py

index b942de10c137bd5e04fc7a61881af896767a5c85..47828a4adc6e905b1854bf3b6b950574f2603e60 100644 (file)
@@ -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