diff --git a/src/auth/operations/update.js b/src/auth/operations/update.js index 0bd27de0c1..ed84a16f41 100644 --- a/src/auth/operations/update.js +++ b/src/auth/operations/update.js @@ -28,7 +28,7 @@ async function update(args) { // 1. Execute access // ///////////////////////////////////// - const accessResults = !overrideAccess ? await executeAccess({ req }, collectionConfig.access.update) : true; + const accessResults = !overrideAccess ? await executeAccess({ req, id }, collectionConfig.access.update) : true; const hasWhereAccess = typeof accessResults === 'object'; // ///////////////////////////////////// @@ -91,6 +91,7 @@ async function update(args) { data = await this.performFieldOperations(collectionConfig, { data, req, + id, hook: 'beforeChange', operation: 'update', originalDoc, @@ -149,6 +150,7 @@ async function update(args) { hook: 'afterRead', operation: 'read', req, + id, depth, overrideAccess, }); diff --git a/src/collections/operations/find.js b/src/collections/operations/find.js index dfdba19cb1..ade59e3d9d 100644 --- a/src/collections/operations/find.js +++ b/src/collections/operations/find.js @@ -100,6 +100,7 @@ async function find(args) { depth, data, req, + id: doc.id, hook: 'afterRead', operation: 'read', overrideAccess, diff --git a/src/collections/operations/findByID.js b/src/collections/operations/findByID.js index d13d413fe4..f21bb036fe 100644 --- a/src/collections/operations/findByID.js +++ b/src/collections/operations/findByID.js @@ -24,7 +24,7 @@ async function findByID(args) { // 1. Retrieve and execute access // ///////////////////////////////////// - const accessResults = !overrideAccess ? await executeAccess({ req, disableErrors }, collectionConfig.access.read) : true; + const accessResults = !overrideAccess ? await executeAccess({ req, disableErrors, id }, collectionConfig.access.read) : true; const hasWhereAccess = typeof accessResults === 'object'; const queryToBuild = { @@ -81,6 +81,7 @@ async function findByID(args) { result = await this.performFieldOperations(collectionConfig, { depth, req, + id, data: result, hook: 'afterRead', operation: 'read', diff --git a/src/collections/operations/update.js b/src/collections/operations/update.js index 63179376d1..c5c609593b 100644 --- a/src/collections/operations/update.js +++ b/src/collections/operations/update.js @@ -33,7 +33,7 @@ async function update(args) { // 1. Execute access // ///////////////////////////////////// - const accessResults = !overrideAccess ? await executeAccess({ req }, collectionConfig.access.update) : true; + const accessResults = !overrideAccess ? await executeAccess({ req, id }, collectionConfig.access.update) : true; const hasWherePolicy = typeof accessResults === 'object'; // ///////////////////////////////////// @@ -96,6 +96,7 @@ async function update(args) { data = await this.performFieldOperations(collectionConfig, { data, req, + id, originalDoc, hook: 'beforeChange', operation: 'update', @@ -185,6 +186,7 @@ async function update(args) { hook: 'afterRead', operation: 'read', req, + id, depth, overrideAccess, }); diff --git a/src/fields/performFieldOperations.js b/src/fields/performFieldOperations.js index 6aa925cb6a..28510569ca 100644 --- a/src/fields/performFieldOperations.js +++ b/src/fields/performFieldOperations.js @@ -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]; diff --git a/src/webpack/getWebpackProdConfig.js b/src/webpack/getWebpackProdConfig.js index d7eb1c8b98..293ec82be2 100644 --- a/src/webpack/getWebpackProdConfig.js +++ b/src/webpack/getWebpackProdConfig.js @@ -1,6 +1,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const Dotenv = require('dotenv-webpack'); -// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); +const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); const webpack = require('webpack'); const path = require('path'); const getStyleLoaders = require('./getStyleLoaders'); @@ -115,7 +115,7 @@ module.exports = (config) => { }; const plugins = [ - // new BundleAnalyzerPlugin(), + new BundleAnalyzerPlugin(), new HtmlWebpackPlugin({ template: config.admin && config.admin.indexHTML ? config.admin.indexHTML : path.resolve(__dirname, '../client/index.html'), filename: './index.html',