aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth/authorisation/resources/views.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-06-17 10:57:17 -0500
committerFrederick Muriuki Muriithi2024-06-17 10:57:17 -0500
commit03bbb4df4e7a6a6b0bbccfabe8a28b380d12bd80 (patch)
tree41981115fa36a1bf36ba56d012e45da3c69216af /gn_auth/auth/authorisation/resources/views.py
parent9f1b11d2756010647051bf213ceed3f374524bbb (diff)
downloadgn-auth-03bbb4df4e7a6a6b0bbccfabe8a28b380d12bd80.tar.gz
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.
Diffstat (limited to 'gn_auth/auth/authorisation/resources/views.py')
-rw-r--r--gn_auth/auth/authorisation/resources/views.py10
1 files changed, 5 insertions, 5 deletions
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."