From 4bd97cb6f245e4c9ce07752d4d041461b6ed0244 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sun, 1 Apr 2018 13:23:40 +0100 Subject: Role requirement decorator should return json on an API error --- pysite/decorators.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pysite/decorators.py') diff --git a/pysite/decorators.py b/pysite/decorators.py index 93e015e4..8abde932 100644 --- a/pysite/decorators.py +++ b/pysite/decorators.py @@ -23,6 +23,9 @@ def require_roles(*roles: int): if role in data["roles"]: return f(self, *args, **kwargs) + if isinstance(self, APIView): + return self.error(ErrorCodes.unauthorized) + raise Forbidden() return redirect(url_for("discord.login")) return inner -- cgit v1.2.3