def decorated_function(*args, **kwargs): api_key = request.headers.get('api_key') user_retrieved = UserModel.find_by_apikey(api_key) if user_retrieved.role == "admin": return view_function(*args, **kwargs) else: abort(401, 'Access denided. Must have admin privileges')
def decorated_function(*args, **kwargs): api_key = request.headers.get('api_key') user_retrieved = UserModel.find_by_apikey(api_key) if user_retrieved: return view_function(*args, **kwargs) else: abort(401, 'Access denided. Invalid API key')
def get(self): api_key = request.headers.get('api_key') u = UserModel.find_by_apikey(api_key) if u: return u.json() return {'message': 'Invalid api_key'}