From 2d0261add8df5a0b49e80eb2fab3a98f27871067 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 17 Jun 2024 15:45:39 -0500 Subject: Fetch the active user's roles on a particular resource. --- gn2/wqflask/oauth2/resources.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gn2/wqflask/oauth2') diff --git a/gn2/wqflask/oauth2/resources.py b/gn2/wqflask/oauth2/resources.py index cf600b51..0befac85 100644 --- a/gn2/wqflask/oauth2/resources.py +++ b/gn2/wqflask/oauth2/resources.py @@ -4,6 +4,7 @@ from flask import ( flash, request, url_for, redirect, Response, Blueprint) from . import client +from . import session from .ui import render_ui as _render_ui from .checks import require_oauth2 from .client import oauth2_get, oauth2_post @@ -408,9 +409,12 @@ def create_resource_role(resource_id: UUID): return render_ui("oauth2/create-role.html", **kwargs) def __fetch_resource_roles__(resource): - return oauth2_get(f"auth/resource/{resource_id}/roles").either( lambda error: __render__(resource_role_error=error), - lambda roles: {"resource": resource, "roles": roles}) + user = session.session_info()["user"] + return oauth2_get( + f"auth/resource/{resource_id}/users/{user['user_id']}" + "/roles").either( + lambda roles: {"resource": resource, "roles": roles}) if request.method == "GET": return oauth2_get(f"auth/resource/view/{resource_id}").map( -- cgit v1.2.3