mirror of
https://github.com/strapi/strapi.git
synced 2025-11-25 14:41:15 +00:00
Fix condition checks
This commit is contained in:
parent
04ac3fb41a
commit
456f945d1e
@ -45,8 +45,6 @@ module.exports = params => {
|
|||||||
permission
|
permission
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(permissionWithSanitizedProperties);
|
|
||||||
|
|
||||||
return permissionWithSanitizedProperties;
|
return permissionWithSanitizedProperties;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -56,18 +56,20 @@ module.exports = {
|
|||||||
* @param {Permission} params.permission
|
* @param {Permission} params.permission
|
||||||
*/
|
*/
|
||||||
const evaluate = async params => {
|
const evaluate = async params => {
|
||||||
const { options, register, permission } = params;
|
const { options, register } = params;
|
||||||
|
|
||||||
const preFormatValidation = await runValidationHook(
|
const preFormatValidation = await runValidationHook(
|
||||||
'before-format::validate.permission',
|
'before-format::validate.permission',
|
||||||
createBeforeEvaluateContext(permission)
|
createBeforeEvaluateContext(params.permission)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (preFormatValidation === false) {
|
if (preFormatValidation === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await state.hooks['format.permission'].call(createFormatContext(permission));
|
const permission = await state.hooks['format.permission'].call(
|
||||||
|
createFormatContext(params.permission)
|
||||||
|
);
|
||||||
|
|
||||||
const postFormatValidation = await runValidationHook(
|
const postFormatValidation = await runValidationHook(
|
||||||
'post-format::validate.permission',
|
'post-format::validate.permission',
|
||||||
@ -114,11 +116,11 @@ module.exports = {
|
|||||||
const resultPropEq = _.propEq('result');
|
const resultPropEq = _.propEq('result');
|
||||||
const pickResults = _.map(_.prop('result'));
|
const pickResults = _.map(_.prop('result'));
|
||||||
|
|
||||||
if (evaluatedConditions.every(resultPropEq(true))) {
|
if (evaluatedConditions.every(resultPropEq(false))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_.isEmpty(evaluatedConditions) || evaluatedConditions.some(resultPropEq(false))) {
|
if (_.isEmpty(evaluatedConditions) || evaluatedConditions.some(resultPropEq(true))) {
|
||||||
return register({ action, subject, properties });
|
return register({ action, subject, properties });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user