diff options
author | 2018-04-01 13:23:40 +0100 | |
---|---|---|
committer | 2018-04-01 13:23:40 +0100 | |
commit | 4bd97cb6f245e4c9ce07752d4d041461b6ed0244 (patch) | |
tree | 4a5e4079099904d28fae2ec1b14468397972e59c | |
parent | Fix logging, restrict staff index route (diff) |
Role requirement decorator should return json on an API error
-rw-r--r-- | pysite/decorators.py | 3 |
1 files changed, 3 insertions, 0 deletions
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 |