aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/decorators.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-04-08 01:07:41 +0100
committerGravatar Gareth Coles <[email protected]>2018-04-08 01:07:41 +0100
commit8235adbecdf09ffe2e8b7a04a38d0be2d86fd5d4 (patch)
treec126eef18d6bb10306d577bb5673a1f2a1bb2e88 /pysite/decorators.py
parent[Wiki] Shorten edit/view links in sidebar (diff)
Easier debugging and optimised imports
Simply set FLASK_DEBUG=1 in your env to skip OAuth checks
Diffstat (limited to 'pysite/decorators.py')
-rw-r--r--pysite/decorators.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/pysite/decorators.py b/pysite/decorators.py
index 426d4846..0b02ebde 100644
--- a/pysite/decorators.py
+++ b/pysite/decorators.py
@@ -8,7 +8,7 @@ from schema import Schema, SchemaError
from werkzeug.exceptions import Forbidden
from pysite.base_route import APIView, BaseView
-from pysite.constants import CSRF, ErrorCodes, ValidationTypes
+from pysite.constants import CSRF, DEBUG_MODE, ErrorCodes, ValidationTypes
def csrf(f):
@@ -32,9 +32,11 @@ def require_roles(*roles: int):
def inner(self: BaseView, *args, **kwargs):
data = self.user_data
- if data:
+ if DEBUG_MODE:
+ return f(self, *args, **kwargs)
+ elif data:
for role in roles:
- if role in data.get("roles", []):
+ if DEBUG_MODE or role in data.get("roles", []):
return f(self, *args, **kwargs)
if isinstance(self, APIView):
@@ -42,6 +44,7 @@ def require_roles(*roles: int):
raise Forbidden()
return redirect(url_for("discord.login"))
+
return inner
return inner_decorator
@@ -128,5 +131,7 @@ def api_params(schema: Schema, validation_type: ValidationTypes = ValidationType
return self.error(ErrorCodes.incorrect_parameters)
return f(self, data, *args, **kwargs)
+
return inner
+
return inner_decorator