aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/authentication_tools.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-06-15 14:40:37 +0300
committerFrederick Muriuki Muriithi2023-06-20 13:36:50 +0300
commitaa4d213692cb27a903fe1593e2dd3387e638b350 (patch)
treef41cfdf7e369cae767af5534cfc02c9998b9e4a2 /wqflask/utility/authentication_tools.py
parenta56d857dc1f6dbc25819a4af116139a2f3e14a68 (diff)
downloadgenenetwork2-aa4d213692cb27a903fe1593e2dd3387e638b350.tar.gz
Configs: Introduce Blueprints. Refactor configs in webqtlConfig.
* Introduce flask Blueprints to help with decoupling the various modules from the `wqflask/__init__.py` module * Refactor settings: Create a function `base.webqtlConfig.init_app(...)` to handle setting up the configurations on the app correctly. Call this function at app creation time. * Move configuration utility functions from `utility.tools` module to `utility.configuration` module. * Use the `get_setting(...)` function to retrieve configuration settings from the application.
Diffstat (limited to 'wqflask/utility/authentication_tools.py')
-rw-r--r--wqflask/utility/authentication_tools.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/wqflask/utility/authentication_tools.py b/wqflask/utility/authentication_tools.py
index 7d80b3fb..3d732228 100644
--- a/wqflask/utility/authentication_tools.py
+++ b/wqflask/utility/authentication_tools.py
@@ -1,7 +1,7 @@
import json
import requests
-from flask import g
+from flask import g, current_app as app
from wqflask.database import database_connection
from base import webqtlConfig
@@ -9,7 +9,7 @@ from utility.redis_tools import (get_redis_conn,
get_resource_info,
get_resource_id,
add_resource)
-from utility.tools import GN_PROXY_URL
+from utility.configuration import get_setting
Redis = get_redis_conn()
@@ -37,7 +37,7 @@ def check_resource_availability(dataset, user_id, trait_id=None):
return webqtlConfig.SUPER_PRIVILEGES
response = None
- the_url = f"{GN_PROXY_URL}available?resource={resource_id}&user={user_id}"
+ the_url = f"{get_setting('GN_PROXY_URL')}available?resource={resource_id}&user={user_id}"
try:
response = json.loads(requests.get(the_url).content)
except:
@@ -93,8 +93,9 @@ def get_group_code(dataset):
def check_admin(resource_id=None):
- the_url = GN_PROXY_URL + "available?resource={}&user={}".format(
- resource_id, g.user_session.user_id)
+ the_url = (
+ f"{get_setting('GN_PROXY_URL')}available?resource={resource_id}"
+ f"&user={g.user_session.user_id}")
try:
response = json.loads(requests.get(the_url).content)['admin']
except: