Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Can i manage access control over the Block field?

default discord avatar
math5362 years 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
    2 years 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
    math536last year

    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
    tombell95last year

    @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
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team..