Merge pull request #761 from coreos-inc/fixtoomanylogin

Move decorator for TooManyLoginAttempts into general decorated module
This commit is contained in:
josephschorr 2015-11-04 12:29:01 -05:00
commit c3a4c36df7
2 changed files with 11 additions and 9 deletions

View file

@ -105,14 +105,6 @@ def handle_api_error(error):
return response 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 resource(*urls, **kwargs):
def wrapper(api_resource): def wrapper(api_resource):
if not api_resource: if not api_resource:

View file

@ -5,6 +5,7 @@ from flask import make_response
from app import app from app import app
from util.useremails import CannotSendEmailException from util.useremails import CannotSendEmailException
from util.config.provider.baseprovider import CannotWriteConfigException from util.config.provider.baseprovider import CannotWriteConfigException
from flask.ext.restful.utils.cors import crossdomain
from data import model from data import model
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -25,4 +26,13 @@ def handle_configexception(ex):
'Please make sure the mounted volume is not read-only and restart ' + 'Please make sure the mounted volume is not read-only and restart ' +
'the setup process. \n\nIssue: %s' % ex) '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