mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-16 20:49:00 -04:00
Merge branch 'master' into load-service-err
This commit is contained in:
@@ -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('There’s something wrong with the link you’ve used.')
|
||||
return _error_response(404)
|
||||
|
||||
|
||||
def setup_event_handlers():
|
||||
from flask_login import user_logged_in
|
||||
|
||||
Reference in New Issue
Block a user