passes id of document to access operations where required

This commit is contained in:
James
2020-08-24 17:02:03 -04:00
parent 45da1369ca
commit b197d780c1
6 changed files with 14 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ async function performFieldOperations(entityConfig, args) {
operation,
hook,
req,
id,
req: {
payloadAPI,
},
@@ -31,7 +32,7 @@ async function performFieldOperations(entityConfig, args) {
const relatedCollection = this.collections[relation];
if (relatedCollection) {
const accessResult = !overrideAccess ? await executeAccess({ req, disableErrors: true }, relatedCollection.config.access.read) : true;
const accessResult = !overrideAccess ? await executeAccess({ req, disableErrors: true, id }, relatedCollection.config.access.read) : true;
let populatedRelationship = null;
@@ -117,7 +118,7 @@ async function performFieldOperations(entityConfig, args) {
const resultingData = data;
if (field.access && field.access[operation]) {
const result = overrideAccess ? true : await field.access[operation]({ req });
const result = overrideAccess ? true : await field.access[operation]({ req, id });
if (!result && operation === 'update' && originalDoc[field.name] !== undefined) {
resultingData[field.name] = originalDoc[field.name];