aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-05-10 15:38:19 +0300
committerFrederick Muriuki Muriithi2023-05-10 15:38:19 +0300
commit96fb589371dd1700f0d0f7abc367098d6820c37a (patch)
tree15b97e602a89d78fa9ebfedd624b3b209035cd0a /wqflask
parent5df9f0400f5457071a6e717ba68d72454f6f07f5 (diff)
downloadgenenetwork2-96fb589371dd1700f0d0f7abc367098d6820c37a.tar.gz
auth: Fetch user collections from GN3
Fetch the user collections from GN3 for users that have authenticated.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/collect.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py
index 18f3091f..2149dd20 100644
--- a/wqflask/wqflask/collect.py
+++ b/wqflask/wqflask/collect.py
@@ -22,6 +22,9 @@ from base.trait import retrieve_trait_info
from base.trait import jsonable
from base.data_set import create_dataset
+from wqflask.oauth2.client import oauth2_get
+from wqflask.oauth2.checks import user_logged_in
+
Redis = get_redis_conn()
@@ -140,6 +143,14 @@ def create_new(collection_name):
def list_collections():
params = request.args
+ if user_logged_in():
+ return oauth2_get("oauth2/user/collections").either(
+ lambda err: __error__(process_error(err)),
+ lambda colls: render_template(
+ "collections/list.html", params=params, collections=colls))
+
+ # TODO: Provide GN3 endpoint to fetch collections for anonymous users
+ # Maybe /oauth2/user/<uuid:anon_user_id>/collections/list
user_collections = list(g.user_session.user_collections)
return render_template("collections/list.html",
params=params,