diff options
| author | Frederick Muriuki Muriithi | 2026-04-08 14:12:55 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-04-08 14:36:32 -0500 |
| commit | 8515d9a495cd4ed4f3ca2287feb30c490a9f2e92 (patch) | |
| tree | 161c1516faa5278b33dd5edd9545b6c007c521d2 /gn_auth/auth/authorisation/users/views.py | |
| parent | ad40f7c7050aac74361699ffa0e27b2fcb93873f (diff) | |
| download | gn-auth-8515d9a495cd4ed4f3ca2287feb30c490a9f2e92.tar.gz | |
user resources: Enable filtering using only the limit and offset.
Diffstat (limited to 'gn_auth/auth/authorisation/users/views.py')
| -rw-r--r-- | gn_auth/auth/authorisation/users/views.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gn_auth/auth/authorisation/users/views.py b/gn_auth/auth/authorisation/users/views.py index cf2a8dc..dc2c1e4 100644 --- a/gn_auth/auth/authorisation/users/views.py +++ b/gn_auth/auth/authorisation/users/views.py @@ -320,12 +320,20 @@ def user_group() -> Response: @require_oauth("profile resource") def user_resources() -> Response: """Retrieve the resources a user has access to.""" + _request_params = request_json() with require_oauth.acquire("profile resource") as the_token: db_uri = current_app.config["AUTH_DB"] with db.connection(db_uri) as conn: - return jsonify([ - asdict(resource) for resource in - _user_resources(conn, the_token.user)]) + _resources, _total_records = _user_resources( + conn, + the_token.user, + start_at=int(_request_params.get("start", 0)), + count=int(_request_params.get("length", 0))) + return jsonify({ + "resources": [asdict(resource) for resource in _resources], + "total-records": _total_records, + "filtered-records": len(_resources) + }) @users.route("group/join-request", methods=["GET"]) @require_oauth("profile group") |
