aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/decorators.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-05-08 11:30:50 +0100
committerGravatar Gareth Coles <[email protected]>2018-05-08 11:30:50 +0100
commit81e32cbb1b9ae40283bcbaef606ef9e09cb71ae6 (patch)
tree07c57d7ae057073c4c586f77e267a0712f6e7833 /pysite/decorators.py
parent[Wiki] Fix an editor dumb: `not not` (diff)
Move bot API key to a constant
Diffstat (limited to '')
-rw-r--r--pysite/decorators.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/pysite/decorators.py b/pysite/decorators.py
index 0c31fe6e..befc0869 100644
--- a/pysite/decorators.py
+++ b/pysite/decorators.py
@@ -1,4 +1,3 @@
-import os
from functools import wraps
from json import JSONDecodeError
@@ -7,7 +6,7 @@ from schema import Schema, SchemaError
from werkzeug.exceptions import Forbidden
from pysite.base_route import APIView, BaseView
-from pysite.constants import CSRF, DEBUG_MODE, ErrorCodes, ValidationTypes
+from pysite.constants import CSRF, DEBUG_MODE, ErrorCodes, ValidationTypes, BOT_API_KEY
def csrf(f):
@@ -58,7 +57,7 @@ def api_key(f):
@wraps(f)
def inner_decorator(self: APIView, *args, **kwargs):
- if not request.headers.get("X-API-Key") == os.environ.get("BOT_API_KEY"):
+ if not request.headers.get("X-API-Key") == BOT_API_KEY:
return self.error(ErrorCodes.invalid_api_key)
return f(self, *args, **kwargs)