]> git.lizzy.rs Git - cheatdb.git/blobdiff - app/blueprints/api/endpoints.py
Fix API auth crash and add more error messages
[cheatdb.git] / app / blueprints / api / endpoints.py
index 65af3b0855f4e4c661fa86b56a24fd0559aa5eb7..29a9ec2c6519dd0765a518afae36e03f083fd880 100644 (file)
@@ -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"])