From 03bbb4df4e7a6a6b0bbccfabe8a28b380d12bd80 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 17 Jun 2024 10:57:17 -0500 Subject: Use the form's json attribute to retrieve sent data The system uses JSON as the default communication format, so we use the form's json attribute to get any data sent. --- gn_auth/auth/authorisation/resources/views.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gn_auth/auth/authorisation/resources/views.py') diff --git a/gn_auth/auth/authorisation/resources/views.py b/gn_auth/auth/authorisation/resources/views.py index a98f404..4583346 100644 --- a/gn_auth/auth/authorisation/resources/views.py +++ b/gn_auth/auth/authorisation/resources/views.py @@ -53,7 +53,7 @@ def list_resource_categories() -> Response: def create_resource() -> Response: """Create a new resource""" with require_oauth.acquire("profile group resource") as the_token: - form = request.form + form = request.json resource_name = form.get("resource_name") resource_category_id = UUID(form.get("resource_category")) db_uri = app.config["AUTH_DB"] @@ -126,7 +126,7 @@ def view_resource_data(resource_id: UUID) -> Response: def link_data(): """Link group data to a specific resource.""" try: - form = request.form + form = request.json assert "resource_id" in form, "Resource ID not provided." assert "data_link_id" in form, "Data Link ID not provided." assert "dataset_type" in form, "Dataset type not specified" @@ -150,7 +150,7 @@ def link_data(): def unlink_data(): """Unlink data bound to a specific resource.""" try: - form = request.form + form = request.json assert "resource_id" in form, "Resource ID not provided." assert "data_link_id" in form, "Data Link ID not provided." @@ -239,7 +239,7 @@ def assign_role_to_user(resource_id: UUID) -> Response: """Assign a role on the specified resource to a user.""" with require_oauth.acquire("profile group resource role") as the_token: try: - form = request.form + form = request.json group_role_id = form.get("group_role_id", "") user_email = form.get("user_email", "") assert bool(group_role_id), "The role must be provided." @@ -264,7 +264,7 @@ def unassign_role_to_user(resource_id: UUID) -> Response: """Unassign a role on the specified resource from a user.""" with require_oauth.acquire("profile group resource role") as the_token: try: - form = request.form + form = request.json group_role_id = form.get("group_role_id", "") user_id = form.get("user_id", "") assert bool(group_role_id), "The role must be provided." -- cgit v1.2.3