diff options
author | 2018-04-04 14:35:07 +0100 | |
---|---|---|
committer | 2018-04-04 14:35:07 +0100 | |
commit | 890d43f852118e6ce1a8108f353327205939779f (patch) | |
tree | f665f1c5cb5c55aae42ec8442ff4648de3c0887b /pysite | |
parent | CSRF error route for API (diff) |
CSRF error route doesn't do shit, sadly
Diffstat (limited to 'pysite')
-rw-r--r-- | pysite/views/api/error_view_csrf.py | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/pysite/views/api/error_view_csrf.py b/pysite/views/api/error_view_csrf.py deleted file mode 100644 index bfa29709..00000000 --- a/pysite/views/api/error_view_csrf.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding=utf-8 -from flask import jsonify -from flask_wtf.csrf import CSRFError -from werkzeug.exceptions import HTTPException - -from pysite.base_route import ErrorView -from pysite.constants import ErrorCodes - - -class APIErrorViewCSRF(ErrorView): - name = "error_csrf" - error_code = CSRFError - register_on_app = False - - def __init__(self): - - # Direct errors for all methods at self.return_error - methods = [ - 'get', 'post', 'put', - 'delete', 'patch', 'connect', - 'options', 'trace' - ] - - for method in methods: - setattr(self, method, self.return_error) - - def return_error(self, error: CSRFError): - """ - Return a basic JSON object representing the HTTP error, - as well as propagating its status code - """ - - return jsonify({ - "error_code": ErrorCodes.unauthorized, - "error_message": "Bad CSRF token" - }), error.code |