sumba 2.27.1 → 2.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extend/bajo/hook.js +8 -7
- package/package.json +1 -1
- package/wiki/CHANGES.md +1 -0
package/extend/bajo/hook.js
CHANGED
|
@@ -23,16 +23,16 @@ async function clearCacheUser (id, result) {
|
|
|
23
23
|
|
|
24
24
|
async function applyModelGuard ({ model, q, teamIds, options }) {
|
|
25
25
|
const { get, set, orderBy, intersection, without } = this.app.lib._
|
|
26
|
-
const {
|
|
26
|
+
const { includes } = this.app.lib.aneka
|
|
27
27
|
const { req } = options
|
|
28
28
|
const results = []
|
|
29
29
|
|
|
30
30
|
const guards = await this.getModelGuards()
|
|
31
31
|
const columns = model.getNonVirtualProperties().map(prop => prop.name)
|
|
32
32
|
const filterFn = item => {
|
|
33
|
-
const bySiteId = item.siteIds.includes(req.site.id + '')
|
|
33
|
+
const bySiteId = item.siteIds ? item.siteIds.includes(req.site.id + '') : true
|
|
34
34
|
const byModel = item.models.includes(model.name)
|
|
35
|
-
const byTeamId = item.teamIds
|
|
35
|
+
const byTeamId = item.teamIds ? includes(item.teamIds, teamIds) : true
|
|
36
36
|
const byColumn = columns.includes(item.column)
|
|
37
37
|
return bySiteId && byModel && byTeamId && byColumn
|
|
38
38
|
}
|
|
@@ -54,7 +54,8 @@ async function applyModelGuard ({ model, q, teamIds, options }) {
|
|
|
54
54
|
for (const item of items) {
|
|
55
55
|
newValues.push(...item.value)
|
|
56
56
|
}
|
|
57
|
-
if (
|
|
57
|
+
if (values.length === 0) values = newValues
|
|
58
|
+
else if (newValues.length > 0) values = intersection(values, newValues)
|
|
58
59
|
items = guards.local.filter(item => item.column === col && item.negation)
|
|
59
60
|
for (const item of items) {
|
|
60
61
|
values = without(values, ...item.value)
|
|
@@ -69,15 +70,15 @@ async function applyModelGuard ({ model, q, teamIds, options }) {
|
|
|
69
70
|
|
|
70
71
|
export async function applyAttribGuard ({ model, teamIds, options }) {
|
|
71
72
|
const { uniq } = this.app.lib._
|
|
72
|
-
const {
|
|
73
|
+
const { includes } = this.app.lib.aneka
|
|
73
74
|
const { req } = options
|
|
74
75
|
const results = []
|
|
75
76
|
|
|
76
77
|
const guards = await this.getAttribGuards()
|
|
77
78
|
const filterFn = item => {
|
|
78
|
-
const bySiteId = item.siteIds.includes(req.site.id + '')
|
|
79
|
+
const bySiteId = item.siteIds ? item.siteIds.includes(req.site.id + '') : true
|
|
79
80
|
const byModel = item.models.includes(model.name)
|
|
80
|
-
const byTeamId = item.teamIds
|
|
81
|
+
const byTeamId = item.teamIds ? includes(item.teamIds, teamIds) : true
|
|
81
82
|
return bySiteId && byModel && byTeamId
|
|
82
83
|
}
|
|
83
84
|
|
package/package.json
CHANGED