Can i manage access control over the Block field?

default discord avatar
math536
12 months ago
3

Is possible to manage access control over the each block field?


Eg: I have an admin user and a customer, but admin can see 5 block type fields, and customers only 2

  • discord user avatar
    jesschow
    Payload Team
    12 months ago

    Currently you cannot apply access control to blocks themselves - however you can restrict access for the fields within the block. If you just need to restrict customers from reading certain data, this could be enough for you. Or there might be something more suitable depending on your specific usage - if you want to share more details on your setup here we can discuss.

  • default discord avatar
    math536
    11 months ago

    Hello Jess, thanks for the answare!! I really apreciate your work together with the other members of Payload Team, you are incredible!!!



    i tried to restrict the block field based on my access control rules, but I needed the field to have the same name, to avoid a large variation of data... anyway, I wasn't successful, my solution was to copy the field of blocks from the payload's official code and apply my rules there, that way, my configuration for blocks it is like:


    { type: "blocks", name: "fieldName", labels: {...}, admin: { components: { Field: createBlock({ condition: (args) => myConditionFunction(args) }) } }, }


    i really intresting to make a pull request to transform this functionality native



    @jesschow

  • default discord avatar
    tombell95
    last month

    @math536 what is this

    createBlock

    you created? I have a similar issues and this looks like the best approach so far... option B would be something like this

    https://discord.com/channels/967097582721572934/1052475936181862470
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.