Access Control: How to get information about document being accessed

default discord avatar
shisue
last month

Hi,



I'm trying to create an access control function, which must check if the user id of who is making the request matches the user id stored in that specific collection. My question is, how do I access the fields of the collection that is being interacted with?



The function is isCreator bellow:



access: { create: isFunder, update: isCreator, delete: isAdminOrSelf, read: () => true, },

And it to arrive at something like:



export const isCreator: Access = (req) => { return req.req.user.id === document.data.createdBy; }

Where createdBy is a field that stored the id of the user who created it.



Access Control: How to get information about document being accessed

    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.