Author: tmckay
Date: 2012-12-07 22:08:00 +0000 (Fri, 07 Dec 2012)
New Revision: 5569
Modified:
trunk/cumin/python/cumin/widgets.py
trunk/wooly/python/wooly/__init__.py
Log:
Move the login expiration delta to a single point in the code
Modified: trunk/cumin/python/cumin/widgets.py
===================================================================
--- trunk/cumin/python/cumin/widgets.py 2012-12-07 21:32:38 UTC (rev 5568)
+++ trunk/cumin/python/cumin/widgets.py 2012-12-07 22:08:00 UTC (rev 5569)
@@ -1314,9 +1314,7 @@
login = session.client_session.attributes.get("login_session")
if login:
- when = datetime.now() - timedelta(hours=24)
- if login.created > when:
- return True
+ return session.login_current(login)
elif self.app.auth_proxy or self.app.user:
username = self.app.user
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-12-07 21:32:38 UTC (rev 5568)
+++ trunk/wooly/python/wooly/__init__.py 2012-12-07 22:08:00 UTC (rev 5569)
@@ -299,12 +299,7 @@
pass
def authorized(self, session):
- login = session.client_session.attributes.get("login_session")
- if login:
- when = datetime.now() - timedelta(hours=24)
- if login.created > when:
- return True
- return False
+ return session.login_current()
def redirect_to_login(self, session):
# Redirect to the login page when not logged in.
@@ -772,8 +767,9 @@
self.csrf_value = None
self.post = False
- def login_current(self):
- login = self.client_session.attributes.get("login_session")
+ def login_current(self, login=None):
+ if not login:
+ login = self.client_session.attributes.get("login_session")
if login:
when = datetime.now() - timedelta(hours=24)
if login.created > when:
Show replies by date