diff options
author | zsloan | 2018-08-15 20:25:28 +0000 |
---|---|---|
committer | zsloan | 2018-08-15 20:25:28 +0000 |
commit | ee8e1eacd88399609f530a33e2d91cf7895da5b0 (patch) | |
tree | 21a6319c692ad940456bd125afdb5f032f6de78c | |
parent | 0974f41213e8013116708e146e2bb10518ac2c37 (diff) | |
download | genenetwork2-ee8e1eacd88399609f530a33e2d91cf7895da5b0.tar.gz |
The issue with adding anonymous collections should be fixed now
-rw-r--r-- | wqflask/wqflask/user_manager.py | 12 |
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'] |