From d93b7d79eba47954141ca1be7b4bb657cf1f613a Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 9 Mar 2020 16:30:58 -0500 Subject: Made change that hopefully fixes the Redis issue in production; I think it's because HGETALL returns an empty list instead of None --- wqflask/wqflask/user_session.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wqflask/wqflask/user_session.py b/wqflask/wqflask/user_session.py index 20c8d84d..8d4b915a 100644 --- a/wqflask/wqflask/user_session.py +++ b/wqflask/wqflask/user_session.py @@ -42,7 +42,7 @@ class UserSession(object): """Logged in user handling""" user_cookie_name = 'session_id_v1' - anon_cookie_name = 'anon_user_v1' + anon_cookie_name = 'anon_user_v2' def __init__(self): user_cookie = request.cookies.get(self.user_cookie_name) @@ -66,8 +66,9 @@ class UserSession(object): #ZS: If user correctled logged in but their session expired #ZS: Need to test this by setting the time-out to be really short or something - if not self.record: + if not self.record or self.record == []: if user_cookie: + logger.debug("NOT RECORD YES USER COOKIE") self.logged_in = False ########### Grrr...this won't work because of the way flask handles cookies @@ -78,6 +79,7 @@ class UserSession(object): #return response #return else: + logger.debug("NOT RECORD NO USER COOKIE") self.record = dict(login_time = time.time(), user_type = "anon", user_id = str(uuid.uuid4())) @@ -85,6 +87,7 @@ class UserSession(object): Redis.hmset(self.redis_key, self.record) Redis.expire(self.redis_key, THIRTY_DAYS) else: + logger.debug("YES SELF.RECORD") if user_cookie: self.logged_in = True @@ -128,6 +131,8 @@ class UserSession(object): else: #ZS: Anonymous user return None + logger.debug("REDIS USER ID:", user_id) + return user_id @property -- cgit v1.2.3