diff options
author | Frederick Muriuki Muriithi | 2023-01-30 03:23:19 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-01-30 03:23:19 +0300 |
commit | 920648f55475ad706828f696141dcd07edb1ef73 (patch) | |
tree | 5ba859f47c164cec3e78f286b33168bdb673870c /gn3/auth/authorisation/views.py | |
parent | c7f3860a33b9adf327bb1f0f8ad15b3c0753ab55 (diff) | |
download | genenetwork3-920648f55475ad706828f696141dcd07edb1ef73.tar.gz |
auth: API: retrieve resources
Diffstat (limited to 'gn3/auth/authorisation/views.py')
-rw-r--r-- | gn3/auth/authorisation/views.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gn3/auth/authorisation/views.py b/gn3/auth/authorisation/views.py index 4ff82c9..65b1dc4 100644 --- a/gn3/auth/authorisation/views.py +++ b/gn3/auth/authorisation/views.py @@ -11,6 +11,7 @@ from gn3.auth.dictify import dictify from gn3.auth.blueprint import oauth2 from .errors import UserRegistrationError +from .resources import user_resources as _user_resources from .roles import user_role, assign_default_roles, user_roles as _user_roles from .groups import ( all_groups, GroupCreationError, user_group as _user_group, @@ -177,3 +178,13 @@ def user_group(): with db.connection(db_uri) as conn, db.cursor(conn) as cursor: return _user_group(cursor, the_token.user).either( __raise_error__, lambda grp: jsonify(dictify(grp))) + +@oauth2.route("/user-resources") +@require_oauth("profile resource") +def user_resources(): + with require_oauth.acquire("profile resource") as the_token: + db_uri = current_app.config["AUTH_DB"] + with db.connection(db_uri) as conn, db.cursor(conn) as cursor: + return jsonify([ + dictify(resource) for resource in + _user_resources(conn, the_token.user)]) |