Skip to content

Commit

Permalink
Add jwt and debugging to list_curations
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakolusheva committed Apr 15, 2021
1 parent 6369848 commit 10c8e3c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions emmaa_service/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1751,10 +1751,12 @@ def submit_curation_endpoint(hash_val, **kwargs):


@app.route('/curation/list/<stmt_hash>/<src_hash>', methods=['GET'])
@jwt_optional
def list_curations(stmt_hash, src_hash):
user, roles = resolve_auth(dict(request.args))
if not roles and not user:
res_dict = {"result": "failure", "reason": "Invalid Credentials"}
logger.debug(res_dict)
return jsonify(res_dict), 401

if user:
Expand All @@ -1764,11 +1766,13 @@ def list_curations(stmt_hash, src_hash):
if not email:
res_dict = {"result": "failure",
"reason": "POST with API key requires a user email."}
logger.debug(res_dict)
return jsonify(res_dict), 400
api_key = roles[0].api_key
if not api_key:
res_dict = {"result": "failure",
"reason": "API key is required to view curations."}
logger.debug(res_dict)
return jsonify(res_dict), 401
curations = get_curations(hash_val=stmt_hash, source_hash=src_hash,
api_key=api_key)
Expand Down

0 comments on commit 10c8e3c

Please sign in to comment.