sumba 2.32.1 → 2.32.3
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
CHANGED
|
@@ -21,7 +21,7 @@ async function clearCacheUser (id, result) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async function applyModelGuard ({ model, q, teamIds, options }) {
|
|
24
|
-
const { set, orderBy } = this.app.lib._
|
|
24
|
+
const { set, orderBy, isEmpty, isArray } = this.app.lib._
|
|
25
25
|
const { includes } = this.app.lib.aneka
|
|
26
26
|
const { sanitizeByType } = this.app.dobo
|
|
27
27
|
const { req } = options
|
|
@@ -39,13 +39,19 @@ async function applyModelGuard ({ model, q, teamIds, options }) {
|
|
|
39
39
|
const rules = orderBy(guards.filter(filterFn), ['field'])
|
|
40
40
|
for (const field of fields) {
|
|
41
41
|
if (!model.getNonVirtualProperties(true).includes(field)) continue // or, should it throws exception instead?
|
|
42
|
+
const opValue = req.getSetting(`sumba:modelGuard.${field}`, {})
|
|
43
|
+
for (const op of ['in', 'nin']) {
|
|
44
|
+
if (!isEmpty(opValue[op]) && isArray(opValue[op])) results.push(set({}, field, set({}, '$' + op, opValue[op])))
|
|
45
|
+
}
|
|
42
46
|
const prop = model.getProperty(field)
|
|
43
47
|
const items = rules.filter(item => item.field === field)
|
|
44
48
|
for (const item of items) {
|
|
45
|
-
|
|
49
|
+
let values = item.value.map(val => {
|
|
46
50
|
return sanitizeByType(val, prop.type, { strict: true, inputFormat: 'string', model: model.name })
|
|
47
51
|
})
|
|
48
52
|
const op = item.condition.toLowerCase()
|
|
53
|
+
if (['in', 'nin'].includes(op) && !isEmpty(opValue[op]) && isArray(opValue[op])) values = values.filter(val => opValue[op].includes(val))
|
|
54
|
+
if (isEmpty(values)) continue
|
|
49
55
|
let value
|
|
50
56
|
if (['in', 'nin'].includes(op)) value = set({}, '$' + op, values)
|
|
51
57
|
else if (op === 'between') value = { $gte: values[0], $lte: values[1] }
|
|
@@ -86,7 +92,7 @@ async function rebuildFilter (model, filter = {}, options = {}) {
|
|
|
86
92
|
const hasTeamId = model.hasProperty('teamId')
|
|
87
93
|
const teams = get(req, 'user.teams', [])
|
|
88
94
|
const teamIds = teams.map(team => team.id + '')
|
|
89
|
-
const aliases = teams.map(team => team.alias)
|
|
95
|
+
// const aliases = teams.map(team => team.alias)
|
|
90
96
|
const q = { $and: [] }
|
|
91
97
|
|
|
92
98
|
filter.query = filter.query ?? {}
|
|
@@ -99,10 +105,12 @@ async function rebuildFilter (model, filter = {}, options = {}) {
|
|
|
99
105
|
return
|
|
100
106
|
}
|
|
101
107
|
if (hasSiteId) q.$and.push({ siteId: req.site.id + '' })
|
|
108
|
+
/*
|
|
102
109
|
if (aliases.includes('administrator')) {
|
|
103
110
|
filter.query = q
|
|
104
111
|
return
|
|
105
112
|
}
|
|
113
|
+
*/
|
|
106
114
|
if (isEmpty(req.user)) {
|
|
107
115
|
if (q.$and.length === 0 && !allowEmpty) throw this.error('_emptyColumnQuery')
|
|
108
116
|
filter.query = q
|
|
@@ -391,7 +399,6 @@ async function hook () {
|
|
|
391
399
|
handler: async function (req, reply) {
|
|
392
400
|
const { getHostname } = this.app.waibu
|
|
393
401
|
req.site = await this.getSite(getHostname(req))
|
|
394
|
-
req.user = {}
|
|
395
402
|
}
|
|
396
403
|
}, {
|
|
397
404
|
name: 'waibu:beforeStart',
|
|
@@ -4,7 +4,7 @@ const apiToken = {
|
|
|
4
4
|
const { get } = this.app.lib._
|
|
5
5
|
const uid = get(req, 'user.id')
|
|
6
6
|
if (!uid) return ''
|
|
7
|
-
const rec = await this.app.dobo.getModel('SumbaUser').getRecord(
|
|
7
|
+
const rec = await this.app.dobo.getModel('SumbaUser').getRecord(uid, { forceNoHidden: true, noCache: true })
|
|
8
8
|
return (await this.createJwtFromUserRecord(rec)).token
|
|
9
9
|
}
|
|
10
10
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## 2026-06-12
|
|
4
4
|
|
|
5
|
+
- [2.32.3] Bug fix in ```hook.js```
|
|
6
|
+
|
|
7
|
+
## 2026-06-12
|
|
8
|
+
|
|
9
|
+
- [2.32.2] Bug fix in ```preRequest``` hook
|
|
10
|
+
|
|
11
|
+
## 2026-06-12
|
|
12
|
+
|
|
5
13
|
- [2.32.0] Necessary updates to ```bajo@2.18.0``` specs
|
|
6
14
|
- [2.32.0] Bug fix in ```_getGuards()```
|
|
7
15
|
- [2.32.0] Bug fix in ```getAttribGuards()```
|