Hi,
I'm trying to write quite a simple validation function. If a user adds an organization, he must be a manager of that organization:
`// Organization added must include the ID of the user creating the cluster.
// Admins have free pass
validate: async (req, { user, data }) => {
if (user.roles.includes('admin')) {
return true;
}
const organization = await payload.find({
collection: 'organizations',
depth: 1,
where: {
id: {
equals: data.organization,
},
},
});
if (organization[0]?.managers.includes(user.id)) {
return true;
}
return false;
},`
The user is logged in, and I have used this exact same logic before. I get the following error