relationAuth中把updateFree的判断下降到每一层上
This commit is contained in:
parent
7dcbcd0abf
commit
c2a5e1bda1
|
|
@ -79,7 +79,7 @@ function createUniqueCheckers(schema) {
|
|||
entity,
|
||||
action: 'create',
|
||||
type: 'logicalData',
|
||||
priority: types_1.CHECKER_MAX_PRIORITY,
|
||||
priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低,所有前置的checker/trigger将数据完整之后再在这里检测
|
||||
checker: (operation, context) => {
|
||||
const { data } = operation;
|
||||
if (data instanceof Array) {
|
||||
|
|
@ -95,9 +95,9 @@ function createUniqueCheckers(schema) {
|
|||
}
|
||||
}, {
|
||||
entity,
|
||||
action: 'update',
|
||||
action: 'update', // 只检查update,其它状态转换的action应该不会涉及unique约束的属性
|
||||
type: 'logicalData',
|
||||
priority: types_1.CHECKER_MAX_PRIORITY,
|
||||
priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低,所有前置的checker/trigger将数据完整之后再在这里检测
|
||||
checker: (operation, context) => {
|
||||
const { data, filter: operationFilter } = operation;
|
||||
if (data) {
|
||||
|
|
@ -227,7 +227,7 @@ function createActionTransformerCheckers(actionDefDict) {
|
|||
action: 'create',
|
||||
type: 'logical',
|
||||
entity,
|
||||
priority: 10,
|
||||
priority: 10, // 优先级要高,先于真正的data检查进行
|
||||
checker: (operation) => {
|
||||
const { data } = operation;
|
||||
if (data instanceof Array) {
|
||||
|
|
|
|||
|
|
@ -1045,6 +1045,11 @@ class RelationAuth {
|
|||
if (actionAuths && actionAuths.length > 0) {
|
||||
return checkChildren(actionAuths);
|
||||
}
|
||||
// 如果这个entity是updateFree,直接过掉到子结点判定
|
||||
const { action, entity } = node;
|
||||
if (this.updateFreeDict[entity] && this.updateFreeDict[entity].includes(action)) {
|
||||
return checkChildren([]);
|
||||
}
|
||||
// 没有能根据父亲传下来的actionAuth判定,只能自己找
|
||||
const result = this.findActionAuthsOnNode(node, context);
|
||||
const checkResult = (result2) => {
|
||||
|
|
@ -1083,9 +1088,6 @@ class RelationAuth {
|
|||
}
|
||||
checkOperation(entity, operation, context) {
|
||||
const { action, filter, data } = operation;
|
||||
if (this.updateFreeDict[entity] && this.updateFreeDict[entity].includes(action)) {
|
||||
return true;
|
||||
}
|
||||
const userId = context.getCurrentUserId();
|
||||
if (!userId) {
|
||||
throw new types_1.OakUnloggedInException();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/// <reference types="node" />
|
||||
/**
|
||||
* 防止assert打包体积过大,从这里引用
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ function destructRelationPath(schema, entity, path, relationFilter, recursive) {
|
|||
},
|
||||
filter: relationFilter,
|
||||
} // as ED['userRelation']['Selection']
|
||||
},
|
||||
}, // as ED[keyof ED]['Projection'],
|
||||
getData: (d) => {
|
||||
return d.userRelation$entity;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1358,9 +1358,14 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict> {
|
|||
return checkChildren(actionAuths);
|
||||
}
|
||||
|
||||
// 如果这个entity是updateFree,直接过掉到子结点判定
|
||||
const { action, entity } = node;
|
||||
if (this.updateFreeDict[entity] && this.updateFreeDict[entity]!.includes(action)) {
|
||||
return checkChildren([]);
|
||||
}
|
||||
|
||||
// 没有能根据父亲传下来的actionAuth判定,只能自己找
|
||||
const result = this.findActionAuthsOnNode(node, context);
|
||||
|
||||
const checkResult = (result2: false | ED['actionAuth']['Schema'][]) => {
|
||||
if (result2 === false) {
|
||||
return false;
|
||||
|
|
@ -1407,9 +1412,6 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict> {
|
|||
context: Cxt,
|
||||
) {
|
||||
const { action, filter, data } = operation;
|
||||
if (this.updateFreeDict[entity] && this.updateFreeDict[entity]!.includes(action)) {
|
||||
return true;
|
||||
}
|
||||
const userId = context.getCurrentUserId();
|
||||
if (!userId) {
|
||||
throw new OakUnloggedInException();
|
||||
|
|
|
|||
Loading…
Reference in New Issue