Problem to set a new Role-Based Access Control in V4

System Information
  • Strapi Version: 4.21.1
  • Database: Mysql
  • Node Version: 18.19.0
  • NPM Version: 10.2.3

I’m trying to create an access rule through RBAC, but I’m facing a problem:

I have two tables that relate to each other:

posts (id, title, content, slug, category, etc…)
categories (id, name, slug).

Each post has only one category.

My intention is to create a role that can only access posts from certain categories.

I tried to create the following condition:

const conditions = [
  {
    displayName: "Allow only category 34508",
    name: "allow-category-34508",
    handler: (user) => {
      return {
        $or: [
          { category: 34508  }
        ]
      };
    },
  }
];


This rule seems to work because the number of records returned is correct (only posts with category = 34508) But all lines return empty fields.

When trying to click on an article, access is denied.
Does anyone know what the problem could be?