change UTC to GMT and add a method for generating the expires int and string

This commit is contained in:
Damien Churchill 2009-09-08 09:55:19 +00:00
parent 2caee15f7f
commit aca9e853d7

View File

@ -81,6 +81,12 @@ def get_session_id(session_id):
log.exception(e) log.exception(e)
return None return None
def make_expires(timeout):
expires = int(time.time()) + timeout
expires_str = time.strftime('%a, %d %b %Y %H:%M:%S GMT',
time.gmtime(expires))
return expires, expires_str
class Auth(JSONComponent): class Auth(JSONComponent):
""" """
The component that implements authentification into the JSON interface. The component that implements authentification into the JSON interface.
@ -124,10 +130,7 @@ class Auth(JSONComponent):
config = component.get("DelugeWeb").config config = component.get("DelugeWeb").config
expires = int(time.time()) + config["session_timeout"] expires, expires_str = make_expires(config["session_timeout"])
expires_str = time.strftime('%a, %d %b %Y %H:%M:%S UTC',
time.gmtime(expires))
checksum = str(make_checksum(session_id)) checksum = str(make_checksum(session_id))
request.addCookie('_session_id', session_id + checksum, request.addCookie('_session_id', session_id + checksum,
@ -223,9 +226,7 @@ class Auth(JSONComponent):
else: else:
session = config["sessions"][session_id] session = config["sessions"][session_id]
auth_level = session["level"] auth_level = session["level"]
expires = int(time.time()) + config["session_timeout"] expires, expires_str = make_expires(config["session_timeout"])
expires_str = time.strftime('%a, %d %b %Y %H:%M:%S UTC',
time.gmtime(expires))
session["expires"] = expires session["expires"] = expires
_session_id = request.getCookie("_session_id") _session_id = request.getCookie("_session_id")