aboutsummaryrefslogtreecommitdiff
path: root/app/blueprints/api/endpoints.py
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2020-05-19 17:24:57 +0100
committerrubenwardy <rw@rubenwardy.com>2020-05-19 17:24:57 +0100
commita36e233051b35d3ca44b5bd38f8f6262c16c1833 (patch)
tree036363e023375185581d0ac50a84eab33c55c199 /app/blueprints/api/endpoints.py
parent8484c0f0aa8bcb02a234c816a75a423737b0297c (diff)
downloadcheatdb-a36e233051b35d3ca44b5bd38f8f6262c16c1833.tar.xz
Fix API auth crash and add more error messagesv1.25.1
Diffstat (limited to 'app/blueprints/api/endpoints.py')
-rw-r--r--app/blueprints/api/endpoints.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/app/blueprints/api/endpoints.py b/app/blueprints/api/endpoints.py
index 65af3b0..29a9ec2 100644
--- a/app/blueprints/api/endpoints.py
+++ b/app/blueprints/api/endpoints.py
@@ -143,19 +143,21 @@ def markdown():
@is_package_page
@is_api_authd
def create_release(token, package):
+ if not token:
+ error(401, "Authentication needed")
+
if not package.checkPerm(token.owner, Permission.APPROVE_RELEASE):
- return error(403, "You do not have the permission to approve releases")
+ error(403, "You do not have the permission to approve releases")
json = request.json
if json is None:
- return error(400, "JSON post data is required")
+ error(400, "JSON post data is required")
for option in ["method", "title", "ref"]:
if json.get(option) is None:
- return error(400, option + " is required in the POST data")
-
+ error(400, option + " is required in the POST data")
if json["method"].lower() != "git":
- return error(400, "Release-creation methods other than git are not supported")
+ error(400, "Release-creation methods other than git are not supported")
return handleCreateRelease(token, package, json["title"], json["ref"])