Merge branch 'master' into load-service-err

This commit is contained in:
Leo Hemsted
2017-11-01 16:43:51 +00:00
committed by GitHub
27 changed files with 758 additions and 319 deletions

View File

@@ -5,6 +5,7 @@ from time import monotonic
import itertools
import ago
from itsdangerous import BadSignature
from flask import (
Flask,
session,
@@ -13,7 +14,8 @@ from flask import (
current_app,
request,
g,
url_for
url_for,
flash
)
from flask._compat import string_types
from flask.globals import _lookup_req_object, _request_ctx_stack
@@ -451,7 +453,7 @@ def useful_headers_after_request(response):
return response
def register_errorhandlers(application):
def register_errorhandlers(application): # noqa (C901 too complex)
def _error_response(error_code):
application.logger.exception('Admin app errored with %s', error_code)
resp = make_response(render_template("error/{0}.html".format(error_code)), error_code)
@@ -505,6 +507,12 @@ def register_errorhandlers(application):
raise error
return _error_response(500)
@application.errorhandler(BadSignature)
def handle_bad_token(error):
# if someone has a malformed token
flash('Theres something wrong with the link youve used.')
return _error_response(404)
def setup_event_handlers():
from flask_login import user_logged_in