Merge branch 'master' of github.com:trouble/payload
This commit is contained in:
@@ -16,10 +16,19 @@ const accessPromise = async ({
|
||||
}) => {
|
||||
const resultingData = data;
|
||||
|
||||
if (field.access && field.access[operation]) {
|
||||
const result = overrideAccess ? true : await field.access[operation]({ req, id });
|
||||
let accessOperation;
|
||||
|
||||
if (!result && operation === 'update' && originalDoc[field.name] !== undefined) {
|
||||
if (hook === 'afterRead') {
|
||||
accessOperation = 'read';
|
||||
} else if (hook === 'beforeValidate') {
|
||||
if (operation === 'update') accessOperation = 'update';
|
||||
if (operation === 'create') accessOperation = 'create';
|
||||
}
|
||||
|
||||
if (field.access && field.access[accessOperation]) {
|
||||
const result = overrideAccess ? true : await field.access[accessOperation]({ req, id });
|
||||
|
||||
if (!result && accessOperation === 'update' && originalDoc[field.name] !== undefined) {
|
||||
resultingData[field.name] = originalDoc[field.name];
|
||||
} else if (!result) {
|
||||
delete resultingData[field.name];
|
||||
|
||||
@@ -23,7 +23,7 @@ const hookPromise = async ({
|
||||
data: fullData,
|
||||
operation,
|
||||
req,
|
||||
});
|
||||
}) || data[field.name];
|
||||
|
||||
if (hookedValue !== undefined) {
|
||||
resultingData[field.name] = hookedValue;
|
||||
|
||||
@@ -6,7 +6,7 @@ const validationPromise = async ({
|
||||
field,
|
||||
path,
|
||||
}) => {
|
||||
if (hook === 'beforeValidate') return true;
|
||||
if (hook !== 'beforeChange') return true;
|
||||
|
||||
const hasCondition = field.admin && field.admin.condition;
|
||||
const shouldValidate = field.validate && !hasCondition;
|
||||
|
||||
Reference in New Issue
Block a user