code: def verify_record_permission(permission_factory, record):
      
      # Note, cannot be done in one line due overloading of boolean
      # operations permission object.
      if not permission_factory(record=record).can():
          from flask_login import current_user
          if not current_user.is_authenticated:
              abort(401)
          abort(403)
docs: Check that the current user has the required permissions on record.
  
      In case the permission check fails, an Flask abort is launched.
      If the user was previously logged-in, a HTTP error 403 is returned.
      Otherwise, is returned a HTTP error 401.
  
      :param permission_factory: permission factory used to check permissions.
      :param record: record whose access is limited.