From 05628e484fb238cea6ac3267be959b2bb0702c61 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 27 Oct 2022 12:20:35 +0300 Subject: Refactor: Pass user id to `check_resource_availability` * Pass the user_id for the current user to the `check_resource_availability` function as an argument, rather than using the global `g.user_session.user_id` value. --- wqflask/utility/authentication_tools.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'wqflask/utility') diff --git a/wqflask/utility/authentication_tools.py b/wqflask/utility/authentication_tools.py index a8c03fe2..7d80b3fb 100644 --- a/wqflask/utility/authentication_tools.py +++ b/wqflask/utility/authentication_tools.py @@ -13,7 +13,7 @@ from utility.tools import GN_PROXY_URL Redis = get_redis_conn() -def check_resource_availability(dataset, trait_id=None): +def check_resource_availability(dataset, user_id, trait_id=None): # At least for now assume temporary entered traits are accessible if type(dataset) == str or dataset.type == "Temp": return webqtlConfig.DEFAULT_PRIVILEGES @@ -33,14 +33,11 @@ def check_resource_availability(dataset, trait_id=None): # 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 user_id in Redis.smembers("super_users"): return webqtlConfig.SUPER_PRIVILEGES response = None - - the_url = GN_PROXY_URL + "available?resource={}&user={}".format( - resource_id, g.user_session.user_id) - + the_url = f"{GN_PROXY_URL}available?resource={resource_id}&user={user_id}" try: response = json.loads(requests.get(the_url).content) except: -- cgit v1.2.3