diff options
author | zsloan | 2021-02-18 18:21:23 +0000 |
---|---|---|
committer | zsloan | 2021-02-18 18:21:23 +0000 |
commit | f1f80b480ea0f71b7ea34f0b23ad136a56e1bc21 (patch) | |
tree | 9bc5bb025457fef15ddb97309fe5d3ffca7eabb7 /wqflask/utility | |
parent | a1c1312037176364024a1d926e9fc76c7ee8c12f (diff) | |
download | genenetwork2-f1f80b480ea0f71b7ea34f0b23ad136a56e1bc21.tar.gz |
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)
Diffstat (limited to 'wqflask/utility')
-rw-r--r-- | wqflask/utility/authentication_tools.py | 19 |
1 files changed, 10 insertions, 9 deletions
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) |