aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-10-27 12:20:35 +0300
committerFrederick Muriuki Muriithi2022-10-28 15:57:56 +0300
commit05628e484fb238cea6ac3267be959b2bb0702c61 (patch)
tree9fb701bc4cb8878d5a3f63d49e5f6520cb14783f /wqflask/utility
parent560eb051e127fe4b8b93104200fe55512a72038f (diff)
downloadgenenetwork2-05628e484fb238cea6ac3267be959b2bb0702c61.tar.gz
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.
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/authentication_tools.py9
1 files changed, 3 insertions, 6 deletions
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: