sumba 2.26.1 → 2.27.0
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 +0 -32
- package/extend/dobo/fixture/team-user.json +2 -2
- package/extend/dobo/model.js +49 -7
- package/lib/create-new-site.js +2 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +7 -0
package/extend/bajo/hook.js
CHANGED
|
@@ -255,14 +255,6 @@ async function hook () {
|
|
|
255
255
|
{ payload, options, source: this.ns }
|
|
256
256
|
)
|
|
257
257
|
}
|
|
258
|
-
}, {
|
|
259
|
-
name: 'dobo.sumbaUser:afterRecordValidation',
|
|
260
|
-
handler: async function (body, options) {
|
|
261
|
-
const { isBcrypt, hash } = this.app.bajoExtra
|
|
262
|
-
const { has } = this.app.lib._
|
|
263
|
-
|
|
264
|
-
if (has(body, 'password') && !isBcrypt(body.password)) body.password = await hash(body.password, 'bcrypt')
|
|
265
|
-
}
|
|
266
258
|
}, {
|
|
267
259
|
name: 'dobo.sumbaUser:afterRemoveRecord',
|
|
268
260
|
handler: async function (id, rec, options = {}) {
|
|
@@ -303,30 +295,6 @@ async function hook () {
|
|
|
303
295
|
)
|
|
304
296
|
}
|
|
305
297
|
}
|
|
306
|
-
}, {
|
|
307
|
-
name: 'dobo.sumbaUser:beforeCreateRecord',
|
|
308
|
-
handler: async function (body, options = {}) {
|
|
309
|
-
const { token, salt } = await this.resetToken()
|
|
310
|
-
body.token = token
|
|
311
|
-
body.salt = salt
|
|
312
|
-
}
|
|
313
|
-
}, {
|
|
314
|
-
name: 'dobo.sumbaUser:beforeRecordValidation',
|
|
315
|
-
handler: async function (body, options = {}) {
|
|
316
|
-
const { set } = this.app.lib._
|
|
317
|
-
const password = await this.passwordRule(options.req)
|
|
318
|
-
const rule = { password }
|
|
319
|
-
set(options, 'validation.params.rule', rule)
|
|
320
|
-
}
|
|
321
|
-
}, {
|
|
322
|
-
name: 'dobo.sumbaUser:beforeUpdateRecord',
|
|
323
|
-
handler: async function (id, body, options = {}) {
|
|
324
|
-
if (body.salt) {
|
|
325
|
-
const { token, salt } = await this.resetToken(body.salt)
|
|
326
|
-
body.token = token
|
|
327
|
-
body.salt = salt
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
298
|
}, {
|
|
331
299
|
level: 1000,
|
|
332
300
|
name: 'dobo.driver:beforeCreateRecord',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[{
|
|
2
2
|
"siteId": "?:SumbaSite::alias:default",
|
|
3
|
-
"userId": "?:SumbaUser::username:admin+siteId
|
|
4
|
-
"teamId": "?:SumbaTeam::alias:administrator+siteId
|
|
3
|
+
"userId": "?:SumbaUser::username:'admin'+siteId:'{siteId}'",
|
|
4
|
+
"teamId": "?:SumbaTeam::alias:'administrator'+siteId:'{siteId}'",
|
|
5
5
|
"_immutable": true
|
|
6
6
|
}]
|
package/extend/dobo/model.js
CHANGED
|
@@ -102,8 +102,11 @@ async function model () {
|
|
|
102
102
|
options
|
|
103
103
|
}, {
|
|
104
104
|
baseName: 'x-route-guard',
|
|
105
|
-
properties: rgProperties.filter(prop =>
|
|
106
|
-
|
|
105
|
+
properties: rgProperties.filter(prop => {
|
|
106
|
+
if (!isString(prop)) return true
|
|
107
|
+
return !(prop.startsWith('teamIds') || prop.startsWith('siteId'))
|
|
108
|
+
}).concat('siteIds,sumba:siteIds'),
|
|
109
|
+
features: rgFeatures,
|
|
107
110
|
options
|
|
108
111
|
}, {
|
|
109
112
|
baseName: 'attrib-guard',
|
|
@@ -113,8 +116,11 @@ async function model () {
|
|
|
113
116
|
buildEnd
|
|
114
117
|
}, {
|
|
115
118
|
baseName: 'x-attrib-guard',
|
|
116
|
-
properties: agProperties.filter(prop =>
|
|
117
|
-
|
|
119
|
+
properties: agProperties.filter(prop => {
|
|
120
|
+
if (!isString(prop)) return true
|
|
121
|
+
return !(prop.startsWith('teamIds') || prop.startsWith('siteId'))
|
|
122
|
+
}).concat('siteIds,sumba:siteIds'),
|
|
123
|
+
features: agFeatures,
|
|
118
124
|
options,
|
|
119
125
|
buildEnd
|
|
120
126
|
}, {
|
|
@@ -125,8 +131,11 @@ async function model () {
|
|
|
125
131
|
buildEnd
|
|
126
132
|
}, {
|
|
127
133
|
baseName: 'x-model-guard',
|
|
128
|
-
properties: mgProperties.filter(prop =>
|
|
129
|
-
|
|
134
|
+
properties: mgProperties.filter(prop => {
|
|
135
|
+
if (!isString(prop)) return true
|
|
136
|
+
return !(prop.startsWith('teamIds') || prop.startsWith('siteId'))
|
|
137
|
+
}).concat('siteIds,sumba:siteIds'),
|
|
138
|
+
features: mgFeatures,
|
|
130
139
|
options,
|
|
131
140
|
buildEnd
|
|
132
141
|
}, {
|
|
@@ -208,7 +217,40 @@ async function model () {
|
|
|
208
217
|
'dobo:createdAt',
|
|
209
218
|
'dobo:updatedAt',
|
|
210
219
|
'dobo:immutable'
|
|
211
|
-
]
|
|
220
|
+
],
|
|
221
|
+
hooks: [{
|
|
222
|
+
name: 'afterRecordValidation',
|
|
223
|
+
handler: async function (body, options) {
|
|
224
|
+
const { isBcrypt, hash } = this.app.bajoExtra
|
|
225
|
+
const { has } = this.app.lib._
|
|
226
|
+
|
|
227
|
+
if (has(body, 'password') && !isBcrypt(body.password)) body.password = await hash(body.password, 'bcrypt')
|
|
228
|
+
}
|
|
229
|
+
}, {
|
|
230
|
+
name: 'beforeCreateRecord',
|
|
231
|
+
handler: async function (body, options = {}) {
|
|
232
|
+
const { token, salt } = await this.plugin.resetToken()
|
|
233
|
+
body.token = token
|
|
234
|
+
body.salt = salt
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
name: 'beforeRecordValidation',
|
|
238
|
+
handler: async function (body, options = {}) {
|
|
239
|
+
const { set } = this.app.lib._
|
|
240
|
+
const password = await this.plugin.passwordRule(options.req)
|
|
241
|
+
const rule = { password }
|
|
242
|
+
set(options, 'validation.params.rule', rule)
|
|
243
|
+
}
|
|
244
|
+
}, {
|
|
245
|
+
name: 'beforeUpdateRecord',
|
|
246
|
+
handler: async function (id, body, options = {}) {
|
|
247
|
+
if (body.salt) {
|
|
248
|
+
const { token, salt } = await this.plugin.resetToken(body.salt)
|
|
249
|
+
body.token = token
|
|
250
|
+
body.salt = salt
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}]
|
|
212
254
|
}]
|
|
213
255
|
}
|
|
214
256
|
|
package/lib/create-new-site.js
CHANGED
|
@@ -61,9 +61,10 @@ export async function createRefs (site, data, options, verbose) {
|
|
|
61
61
|
const fixtures = data[m]
|
|
62
62
|
for (const f of fixtures) {
|
|
63
63
|
f.siteId = site.id
|
|
64
|
+
const lv = {}
|
|
64
65
|
for (const key in f) {
|
|
65
66
|
const val = f[key]
|
|
66
|
-
if (isString(val) && val.slice(0, 2) === '?:') f[key] = await mdl._simpleLookup(val.slice(2), options)
|
|
67
|
+
if (isString(val) && val.slice(0, 2) === '?:') f[key] = await mdl._simpleLookup(val.slice(2), lv, options)
|
|
67
68
|
}
|
|
68
69
|
await mdl.createRecord(f, options)
|
|
69
70
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-05-30
|
|
4
|
+
|
|
5
|
+
- [2.27.0] Move all ```sumbaUser``` hooks to model hooks
|
|
6
|
+
- [2.27.0] Bug fix in ```model.js```
|
|
7
|
+
- [2.27.0] Bug fix in ```create-new-site.js```
|
|
8
|
+
- [2.27.0] Bug fix in ```team-user.json``` fixture
|
|
9
|
+
|
|
3
10
|
## 2026-05-29
|
|
4
11
|
|
|
5
12
|
- [2.26.1] Bug fix in ```util.js```
|