diff --git a/endpoints/api/__init__.py b/endpoints/api/__init__.py index 099076de2..70b76f7e4 100644 --- a/endpoints/api/__init__.py +++ b/endpoints/api/__init__.py @@ -105,14 +105,6 @@ def handle_api_error(error): return response -@api_bp.app_errorhandler(model.TooManyLoginAttemptsException) -@crossdomain(origin='*', headers=['Authorization', 'Content-Type']) -def handle_too_many_login_attempts(error): - response = make_response('Too many login attempts', 429) - response.headers['Retry-After'] = int(error.retry_after) - return response - - def resource(*urls, **kwargs): def wrapper(api_resource): if not api_resource: diff --git a/endpoints/decorated.py b/endpoints/decorated.py index d1e654da0..989459c6f 100644 --- a/endpoints/decorated.py +++ b/endpoints/decorated.py @@ -5,6 +5,7 @@ from flask import make_response from app import app from util.useremails import CannotSendEmailException from util.config.provider.baseprovider import CannotWriteConfigException +from flask.ext.restful.utils.cors import crossdomain from data import model logger = logging.getLogger(__name__) @@ -25,4 +26,13 @@ def handle_configexception(ex): 'Please make sure the mounted volume is not read-only and restart ' + 'the setup process. \n\nIssue: %s' % ex) - return make_response(json.dumps({'message': message}), 400) \ No newline at end of file + return make_response(json.dumps({'message': message}), 400) + +@app.errorhandler(model.TooManyLoginAttemptsException) +@crossdomain(origin='*', headers=['Authorization', 'Content-Type']) +def handle_too_many_login_attempts(error): + msg = 'Too many login attempts. \nPlease reset your Quay password and try again.' + response = make_response(msg, 429) + response.headers['Retry-After'] = int(error.retry_after) + return response +