From 96fb589371dd1700f0d0f7abc367098d6820c37a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 10 May 2023 15:38:19 +0300 Subject: auth: Fetch user collections from GN3 Fetch the user collections from GN3 for users that have authenticated. --- wqflask/wqflask/collect.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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//collections/list user_collections = list(g.user_session.user_collections) return render_template("collections/list.html", params=params, -- cgit v1.2.3