@has_permission @auth_user def add_user(user_info): """ do something """ return None
def auth_user(f): @wraps(f) def wrapper(*args, **kwargs): data = jwt.decode(request.headers['some-access-token'], some_secret_key) try: user_info = User.query.filter(User.id==data['user_id']).first() except: return jsonify({"message" : "error"}), 401 return f(user_info, *args, **kwargs) return wrapper
def has_permission(f): wraps(f) def wrapper(*args, **kwargs): # This is where I want to access the user information instead of processing the key again # # return some new_args ... # return f(*args, **kwargs) return wrapper
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)