在锚定权限判断的对象时,正确处理了entity等于user的情况,以及在对excludePaths的正确处理
This commit is contained in:
parent
5789bbc96e
commit
70dbf3b136
|
|
@ -65,16 +65,27 @@ var RelationAuth = /** @class */ (function () {
|
|||
}
|
||||
else if (rel === 1 && anchors.length === 0) {
|
||||
// 只寻找highest的,有更深的就忽略掉浅的
|
||||
if (attr === 'entity' && pathGroup[filter.entity]) {
|
||||
if (attr === 'entity' && (pathGroup[filter.entity] || filter.entity === 'user')) {
|
||||
var nextPath = path ? "".concat(path, ".").concat(filter.entity) : filter.entity;
|
||||
if (filter.entityId) {
|
||||
anchorsOnMe.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
if (filter.entity === 'user') {
|
||||
anchors.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
}
|
||||
else {
|
||||
anchorsOnMe.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
var attributes = _this.schema[entity].attributes;
|
||||
var ref = attributes.entity.ref;
|
||||
|
|
@ -89,7 +100,7 @@ var RelationAuth = /** @class */ (function () {
|
|||
else if (((_a = _this.schema[entity].attributes[attr]) === null || _a === void 0 ? void 0 : _a.type) === 'ref') {
|
||||
var ref = _this.schema[entity].attributes[attr].ref;
|
||||
(0, assert_1.default)(typeof ref === 'string');
|
||||
if (pathGroup[ref] || ref === 'user') {
|
||||
if (pathGroup[ref]) {
|
||||
anchorsOnMe.push({
|
||||
entity: ref,
|
||||
filter: {
|
||||
|
|
@ -98,6 +109,15 @@ var RelationAuth = /** @class */ (function () {
|
|||
relativePath: path ? "".concat(path, ".").concat(attr.slice(0, attr.length - 2)) : attr.slice(0, attr.length - 2)
|
||||
});
|
||||
}
|
||||
else if (ref === 'user') {
|
||||
anchors.push({
|
||||
entity: ref,
|
||||
filter: {
|
||||
id: filter[attr],
|
||||
},
|
||||
relativePath: path ? "".concat(path, ".").concat(attr.slice(0, attr.length - 2)) : attr.slice(0, attr.length - 2)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -140,7 +160,7 @@ var RelationAuth = /** @class */ (function () {
|
|||
// 被entity的外键连接所排队的路径,这个非常重要,否则像extraFile这样的对象会有过多的查询路径
|
||||
for (var excludePaths_1 = tslib_1.__values(excludePaths), excludePaths_1_1 = excludePaths_1.next(); !excludePaths_1_1.done; excludePaths_1_1 = excludePaths_1.next()) {
|
||||
var excludePath = excludePaths_1_1.value;
|
||||
if (path[1].startsWith(excludePath)) {
|
||||
if (path[1].startsWith("".concat(excludePath, ".")) || path[1] === excludePath) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,16 +107,27 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
|||
}
|
||||
else if (rel === 1 && anchors.length === 0) {
|
||||
// 只寻找highest的,有更深的就忽略掉浅的
|
||||
if (attr === 'entity' && pathGroup[filter.entity]) {
|
||||
if (attr === 'entity' && (pathGroup[filter.entity] || filter.entity === 'user')) {
|
||||
const nextPath = path ? `${path}.${filter.entity as string}` : filter.entity;
|
||||
if (filter.entityId) {
|
||||
anchorsOnMe.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
if (filter.entity === 'user') {
|
||||
anchors.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
}
|
||||
else {
|
||||
anchorsOnMe.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
const { attributes } = this.schema[entity];
|
||||
const { ref } = attributes.entity;
|
||||
|
|
@ -133,7 +144,7 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
|||
else if (this.schema[entity].attributes[attr as any]?.type === 'ref') {
|
||||
const { ref } = this.schema[entity].attributes[attr as any];
|
||||
assert(typeof ref === 'string');
|
||||
if (pathGroup[ref] || ref === 'user') {
|
||||
if (pathGroup[ref]) {
|
||||
anchorsOnMe.push({
|
||||
entity: ref,
|
||||
filter: {
|
||||
|
|
@ -142,6 +153,15 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
|||
relativePath: path ? `${path}.${attr.slice(0, attr.length - 2)}` : attr.slice(0, attr.length - 2)
|
||||
});
|
||||
}
|
||||
else if (ref === 'user') {
|
||||
anchors.push({
|
||||
entity: ref,
|
||||
filter: {
|
||||
id: filter[attr],
|
||||
},
|
||||
relativePath: path ? `${path}.${attr.slice(0, attr.length - 2)}` : attr.slice(0, attr.length - 2)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -190,7 +210,7 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
|||
(path) => {
|
||||
// 被entity的外键连接所排队的路径,这个非常重要,否则像extraFile这样的对象会有过多的查询路径
|
||||
for (const excludePath of excludePaths) {
|
||||
if (path[1].startsWith(excludePath)) {
|
||||
if (path[1].startsWith(`${excludePath}.`) || path[1] === excludePath) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue