aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/user_manager.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py
index 06a3e274..87149cdb 100644
--- a/wqflask/wqflask/user_manager.py
+++ b/wqflask/wqflask/user_manager.py
@@ -56,12 +56,10 @@ class AnonUser(object):
if self.cookie:
logger.debug("ANON COOKIE ALREADY EXISTS")
self.anon_id = verify_cookie(self.cookie)
-
else:
logger.debug("CREATING NEW ANON COOKIE")
self.anon_id, self.cookie = create_signed_cookie()
- res = make_response()
- res.set_cookie(self.cookie_name, self.cookie)
+
self.key = "anon_collection:v1:{}".format(self.anon_id)
def add_collection(self, new_collection):
@@ -132,6 +130,7 @@ class AnonUser(object):
print("Couldn't display_num_collections:", why)
return ""
+
def verify_cookie(cookie):
the_uuid, separator, the_signature = cookie.partition(':')
assert len(the_uuid) == 36, "Is session_id a uuid?"
@@ -412,12 +411,17 @@ def before_request():
g.user_session = UserSession()
g.cookie_session = AnonUser()
+@app.after_request
+def set_cookie(response):
+ if not request.cookies.get(g.cookie_session.cookie_name):
+ response.set_cookie(g.cookie_session.cookie_name, g.cookie_session.cookie)
+ return response
+
class UsersManager(object):
def __init__(self):
self.users = model.User.query.all()
logger.debug("Users are:", self.users)
-
class UserManager(object):
def __init__(self, kw):
self.user_id = kw['user_id']