code: def check_contract_allowed(func):
      
      @wraps(func)
      def decorator(*args, **kwargs):
          contract = kwargs.get('contract')
          if (contract and current_user.is_authenticated()
                  and not current_user.allowed(contract)):
              return current_app.login_manager.unauthorized()
          return func(*args, **kwargs)
      return decorator
docs: Check if Contract is allowed by token