Exemple #1
0
def login_valid():
    """
    Test if api key is valid
    """
    key = request.GET.get('apikey', '')
    if not key and request.json:
        key = request.json.get('apikey', '')
    if not key:
        abort(401, "API key is mandatory")
    for mod in settings.AUTHENTICATION_MODULES:
        if mod.valid_key(key):
            return ret_ok({'message': 'API key is valid'})
    return ret_error('API key is not valid')
Exemple #2
0
def login_valid():
    """
    Test if api key is valid
    """
    key = request.GET.get('apikey', '')
    if not key and request.json:
        key = request.json.get('apikey', '')
    if not key:
        abort(401, "API key is mandatory")
    for mod in settings.AUTHENTICATION_MODULES:
        if mod.valid_key(key):
            return ret_ok({'message': 'API key is valid'})
    return ret_error('API key is not valid')
Exemple #3
0
def error400(error):
    rollback()
    response.content_type = 'application/json'
    data = ret_error('Request is invalid', data={'info': get_error_str(error)})
    return json.dumps(data)
Exemple #4
0
def error500(error):
    rollback()
    response.content_type = 'application/json'
    data = ret_error('Unexcepted error occured',
                     data={'info': get_error_str(error)})
    return json.dumps(data)
Exemple #5
0
def error400(error):
    rollback()
    response.content_type = 'application/json'
    data = ret_error('Request is invalid', data={'info': get_error_str(error)})
    return json.dumps(data)
Exemple #6
0
def error500(error):
    rollback()
    response.content_type = 'application/json'
    data = ret_error('Unexcepted error occured',
                     data={'info': get_error_str(error)})
    return json.dumps(data)