Auth caching
parent
9353681248
commit
9254dbe535
|
@ -48,6 +48,8 @@ class UserManager(object):
|
|||
def hasBeenCustomized(self):
|
||||
return False
|
||||
|
||||
|
||||
USER_CACHE = {}
|
||||
class HackerspaceUserManager(UserManager):
|
||||
"""A user manager for the Warsaw Hackerspace, uses interal apis."""
|
||||
def __init__(self):
|
||||
|
@ -58,11 +60,15 @@ class HackerspaceUserManager(UserManager):
|
|||
return password
|
||||
|
||||
def findUser(self, username=None):
|
||||
if username in USER_CACHE:
|
||||
return USER_CACHE[username]
|
||||
if username == "dummy":
|
||||
return DummyUser()
|
||||
print "finduser: {}".format(username)
|
||||
if requests.get("https://capacifier.hackerspace.pl/{}/{}".format(self.group, username)).status_code == 200:
|
||||
return HackerspaceUser(username)
|
||||
u = HackerspaceUser(username)
|
||||
USER_CACHE[username] = u
|
||||
return u
|
||||
else:
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in New Issue