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
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.