Fix request body handling
Signed-off-by: Tiago Garcia <tiago.rgarcia@ua.pt>
This commit is contained in:
parent
11adcb21ba
commit
0dfb7d939d
|
@ -1,3 +1,4 @@
|
|||
cryptography
|
||||
flask
|
||||
flask_sqlalchemy
|
||||
pytest
|
|
@ -1,3 +1,5 @@
|
|||
import json
|
||||
|
||||
from flask import Blueprint, request, jsonify, send_file, Response
|
||||
|
||||
import utils
|
||||
|
@ -44,6 +46,8 @@ def file_upload_metadata():
|
|||
return session
|
||||
|
||||
data = request.json
|
||||
if type(data) is str:
|
||||
data = json.loads(data)
|
||||
if "document_name" not in data or "key" not in data or "alg" not in data:
|
||||
return jsonify({"error": "Missing required fields"}), 400
|
||||
|
||||
|
@ -98,6 +102,8 @@ def file_list():
|
|||
|
||||
|
||||
data = request.json
|
||||
if type(data) is str:
|
||||
data = json.loads(data)
|
||||
|
||||
org = OrganizationService.get_organization(session.org_id)
|
||||
if not org:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import json
|
||||
from flask import Blueprint, request, jsonify
|
||||
from services import OrganizationService
|
||||
|
||||
|
@ -6,6 +7,8 @@ org_bp = Blueprint("org", __name__)
|
|||
@org_bp.route("/create", methods=["POST"])
|
||||
def org_create():
|
||||
data = request.json
|
||||
if type(data) is str:
|
||||
data = json.loads(data)
|
||||
if "name" not in data or "username" not in data or "full_name" not in data or "email" not in data or "public_key" not in data:
|
||||
return jsonify({"error": "Missing required fields"}), 400
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ user_bp = Blueprint("user", __name__)
|
|||
@user_bp.route("/login", methods=["POST"])
|
||||
def user_login():
|
||||
data = request.json
|
||||
if type(data) is str:
|
||||
data = json.loads(data)
|
||||
|
||||
if "username" not in data or "org" not in data:
|
||||
return jsonify({"error": "Missing required fields"}), 400
|
||||
|
@ -49,6 +51,8 @@ def user_list():
|
|||
return session
|
||||
|
||||
data = request.json
|
||||
if type(data) is str:
|
||||
data = json.loads(data)
|
||||
|
||||
org = OrganizationService.get_organization(session.org_id)
|
||||
if not org:
|
||||
|
@ -75,6 +79,9 @@ def user_create():
|
|||
return session
|
||||
|
||||
data = request.json
|
||||
if type(data) is str:
|
||||
data = json.loads(data)
|
||||
|
||||
if "username" not in data or "full_name" not in data or "email" not in data or "public_key" not in data:
|
||||
return jsonify({"error": "Missing required fields"}), 400
|
||||
|
||||
|
|
Loading…
Reference in New Issue