Move decorator for TooManyLoginAttempts into general decorated module

Currently, this is missing in gunicorn_registry which causes 500s when user logins become throttled
This commit is contained in:
Joseph Schorr 2015-11-03 12:16:01 -05:00
parent 89b6e2f968
commit 5e1cd2b2ad
2 changed files with 11 additions and 9 deletions

View file

@ -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:

View file

@ -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)
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