Exemple #1
0
 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')
Exemple #2
0
 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')
Exemple #3
0
 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'}