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