code: def client_getter():
      
      def wrapper(f):
          @wraps(f)
          def decorated(*args, **kwargs):
              if 'client_id' not in kwargs:
                  abort(500)
  
              client = Client.query.filter_by(
                  client_id=kwargs.pop('client_id'),
                  user_id=current_user.get_id(),
              ).first()
  
              if client is None:
                  abort(404)
  
              return f(client, *args, **kwargs)
          return decorated
      return wrapper
docs: Decorator to retrieve Client object and check user permission.