sumba 2.33.2 → 2.33.4
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 +1 -0
- package/extend/bajo/intl/en-US.json +1 -0
- package/extend/bajo/intl/id.json +1 -0
- package/index.js +5 -5
- package/lib/create-new-site.js +3 -1
- package/lib/get-site.js +1 -1
- package/lib/get-user.js +1 -1
- package/lib/remove-site.js +2 -2
- package/package.json +1 -1
- package/wiki/CHANGES.md +2 -0
package/extend/bajo/hook.js
CHANGED
|
@@ -127,6 +127,7 @@ async function rebuildFilter (model, filter = {}, options = {}) {
|
|
|
127
127
|
const fields = keys(req.getSetting('sumba:modelGuard', {}))
|
|
128
128
|
const results = []
|
|
129
129
|
for (const field of fields) {
|
|
130
|
+
if (!model.hasProperty(field)) continue
|
|
130
131
|
const inSetting = filterModelFromSetting.call(this, { model, field, options })
|
|
131
132
|
if (inSetting.results.length > 0) results.push(...inSetting.results)
|
|
132
133
|
}
|
package/extend/bajo/intl/id.json
CHANGED
package/index.js
CHANGED
|
@@ -190,19 +190,19 @@ async function factory (pkgName) {
|
|
|
190
190
|
}
|
|
191
191
|
if (this.config.xSiteAdmins.length === 0) {
|
|
192
192
|
const site = await getModel('SumbaSite').findOneRecord({ query: { alias: 'default' } }, { noMagic: true })
|
|
193
|
-
const user = await getModel('SumbaUser').findOneRecord({ query: { username: 'admin', siteId: site.id } }, { noMagic: true })
|
|
193
|
+
const user = await getModel('SumbaUser').findOneRecord({ query: { username: 'admin', siteId: site.id + '' } }, { noMagic: true })
|
|
194
194
|
this.config.xSiteAdmins.push(`${site.alias}:${user.username}`)
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
populateRouteGuards = async () => {
|
|
198
|
+
populateRouteGuards = async (sites) => {
|
|
199
199
|
const { isString, get, difference } = this.app.lib._
|
|
200
200
|
const { pascalCase } = this.app.lib.aneka
|
|
201
201
|
const { eachPlugins, readConfig, breakNsPath } = this.app.bajo
|
|
202
202
|
const { getModel } = this.app.dobo
|
|
203
203
|
|
|
204
204
|
const allNs = this.app.getAllNs()
|
|
205
|
-
|
|
205
|
+
if (!sites) sites = await getModel('SumbaSite').findAllRecord({ query: { status: 'ACTIVE' } }, { noMagic: true, dataOnly: true, fields: ['id', 'hostname'] })
|
|
206
206
|
|
|
207
207
|
const sanitize = (item, ns) => {
|
|
208
208
|
if (isString(item)) item = { path: item }
|
|
@@ -257,13 +257,13 @@ async function factory (pkgName) {
|
|
|
257
257
|
const paths = routes.map(item => item.path)
|
|
258
258
|
const model = getModel(pascalCase(`Sumba ${type} Guard`))
|
|
259
259
|
for (const site of sites) {
|
|
260
|
-
const query = { path: { $in: paths }, siteId: site.id }
|
|
260
|
+
const query = { path: { $in: paths }, siteId: site.id + '' }
|
|
261
261
|
const recs = await model.findAllRecord({ query }, { noMagic: true, dataOnly: true, fields: ['path', 'status'] })
|
|
262
262
|
const spaths = difference(paths, recs.map(rec => rec.path))
|
|
263
263
|
for (const path of spaths) {
|
|
264
264
|
const body = cloneDeep(routes.find(r => r.path === path))
|
|
265
265
|
body.status = 'ACTIVE'
|
|
266
|
-
body.siteId = site.id
|
|
266
|
+
body.siteId = site.id + ''
|
|
267
267
|
await model.sanitizeFixture({ body, lookupValue: body })
|
|
268
268
|
try {
|
|
269
269
|
await model.createRecord(body, { noMagic: true, noReturn: true })
|
package/lib/create-new-site.js
CHANGED
|
@@ -66,10 +66,12 @@ export async function createRefs (site, data, options, verbose) {
|
|
|
66
66
|
const val = f[key]
|
|
67
67
|
if (isString(val) && val.slice(0, 2) === '?:') f[key] = await mdl._simpleLookup(val.slice(2), lv, options)
|
|
68
68
|
}
|
|
69
|
-
await mdl.createRecord(f, options)
|
|
69
|
+
await mdl.createRecord(f, { ...options, noFlash: true })
|
|
70
70
|
}
|
|
71
71
|
if (verbose) this.print.succeed('writingModel%s%s', mdl.name, fixtures.length)
|
|
72
72
|
}
|
|
73
|
+
if (verbose) this.print.succeed('populateRouteGuard')
|
|
74
|
+
await this.populateRouteGuards([site])
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
async function createNewSite (alias, hostname, verbose) {
|
package/lib/get-site.js
CHANGED
|
@@ -12,7 +12,7 @@ async function getSite (input, byId = false) {
|
|
|
12
12
|
const names = this.app.getAllNs()
|
|
13
13
|
const query = {
|
|
14
14
|
ns: { $in: names },
|
|
15
|
-
siteId: site.id
|
|
15
|
+
siteId: site.id + ''
|
|
16
16
|
}
|
|
17
17
|
const all = await this.app.dobo.getModel('SumbaSiteSetting').findAllRecord({ query })
|
|
18
18
|
for (const ns of names) {
|
package/lib/get-user.js
CHANGED
|
@@ -78,7 +78,7 @@ export async function getUserByUsernamePassword (username = '', password = '', r
|
|
|
78
78
|
await model.validate({ username, password }, null, { partial: true, ns: ['sumba', 'dobo'], fields: ['username', 'password'] })
|
|
79
79
|
const bcrypt = await importPkg('bajoExtra:bcrypt')
|
|
80
80
|
|
|
81
|
-
const query = { username, provider: 'local', siteId: req.site.id }
|
|
81
|
+
const query = { username, provider: 'local', siteId: req.site.id + '' }
|
|
82
82
|
const user = await model.findOneRecord({ query }, { req, forceNoHidden: true, noHook: true, noDriverHook: true })
|
|
83
83
|
if (!user) throw this.error('validationError', { details: [{ field: 'username', error: 'Unknown username' }], statusCode: 401 })
|
|
84
84
|
if (user.status !== 'ACTIVE') throw this.error('validationError', { details: ['User is inactive or temporarily disabled'], statusCode: 401 })
|
package/lib/remove-site.js
CHANGED
|
@@ -7,12 +7,12 @@ export async function removeRefs (site, options, verbose) {
|
|
|
7
7
|
}).map(m => m.name)
|
|
8
8
|
for (const m of models) {
|
|
9
9
|
const mdl = getModel(m)
|
|
10
|
-
const rows = await mdl.findAllRecord({ query: { siteId: site.id } }, { ...options, dataOnly: true })
|
|
10
|
+
const rows = await mdl.findAllRecord({ query: { siteId: site.id + '' } }, { ...options, dataOnly: true })
|
|
11
11
|
const ids = rows.map(item => item.id)
|
|
12
12
|
// TODO: backup
|
|
13
13
|
if (ids.length === 0) continue
|
|
14
14
|
for (const id of ids) {
|
|
15
|
-
await mdl.removeRecord(id, { noReturn: true, ...options })
|
|
15
|
+
await mdl.removeRecord(id, { noReturn: true, ...options, noFlash: true })
|
|
16
16
|
}
|
|
17
17
|
if (verbose) this.print.succeed('removedFrom%s%s', mdl.name, ids.length)
|
|
18
18
|
}
|
package/package.json
CHANGED