From f1f80b480ea0f71b7ea34f0b23ad136a56e1bc21 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 18 Feb 2021 18:21:23 +0000 Subject: Changed authentication_tools.py to account for encoding str as bytes and dealing with the permissions response either being a list or not a list (this should be temporary until I figure out what is going on here) --- wqflask/utility/authentication_tools.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'wqflask') diff --git a/wqflask/utility/authentication_tools.py b/wqflask/utility/authentication_tools.py index ce0c0749..786475a8 100644 --- a/wqflask/utility/authentication_tools.py +++ b/wqflask/utility/authentication_tools.py @@ -11,7 +11,6 @@ from utility.redis_tools import (get_redis_conn, add_resource) Redis = get_redis_conn() - def check_resource_availability(dataset, trait_id=None): # At least for now assume temporary entered traits are accessible if type(dataset) == str or dataset.type == "Temp": @@ -32,13 +31,14 @@ def check_resource_availability(dataset, trait_id=None): # ZS: Check if super-user - we should probably come up with some # way to integrate this into the proxy - if g.user_session.user_id in Redis.smembers("super_users"): + if str.encode(g.user_session.user_id) in Redis.smembers("super_users"): return webqtlConfig.SUPER_PRIVILEGES response = None the_url = "http://localhost:8080/available?resource={}&user={}".format( resource_id, g.user_session.user_id) + try: response = json.loads(requests.get(the_url).content) except: @@ -101,12 +101,13 @@ def check_admin(resource_id=None): resource_info = get_resource_info(resource_id) response = resource_info['default_mask']['admin'] - if 'edit-admins' in response: - return "edit-admins" - elif 'edit-access' in response: - return "edit-access" - else: - return "not-admin" + if type(response) is list: + if 'edit-admins' in response: + return 'edit_admins' + elif 'edit-access' in response: + return 'edit-access' + + return response def check_owner(dataset=None, trait_id=None, resource_id=None): @@ -131,7 +132,7 @@ def check_owner_or_admin(dataset=None, trait_id=None, resource_id=None): else: resource_id = get_resource_id(dataset, trait_id) - if g.user_session.user_id in Redis.smembers("super_users"): + if str.encode(g.user_session.user_id) in Redis.smembers("super_users"): return "owner" resource_info = get_resource_info(resource_id) -- cgit v1.2.3