5e1cd2b2ad
Currently, this is missing in gunicorn_registry which causes 500s when user logins become throttled
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
import logging
|
|
import json
|
|
|
|
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__)
|
|
|
|
@app.errorhandler(model.DataModelException)
|
|
def handle_dme(ex):
|
|
logger.exception(ex)
|
|
return make_response(json.dumps({'message': ex.message}), 400)
|
|
|
|
@app.errorhandler(CannotSendEmailException)
|
|
def handle_emailexception(ex):
|
|
message = 'Could not send email. Please contact an administrator and report this problem.'
|
|
return make_response(json.dumps({'message': message}), 400)
|
|
|
|
@app.errorhandler(CannotWriteConfigException)
|
|
def handle_configexception(ex):
|
|
message = ('Configuration could not be written to the mounted volume. \n' +
|
|
'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)
|
|
|
|
@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
|
|
|