sumba 1.1.7 → 1.1.8
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/bajo/hook/dobo.sumba-contact-form@before-record-create.js +1 -1
- package/bajo/hook/dobo.sumba-user@after-record-validation.js +1 -1
- package/bajo/hook/dobo.sumba-user@before-record-validation.js +1 -1
- package/bajo/hook/dobo@before-record-create.js +1 -1
- package/bajo/hook/dobo@before-record-find.js +1 -1
- package/dobo/feature/lat-lng.js +1 -1
- package/dobo/feature/slug.js +2 -2
- package/lib/check-iconset.js +1 -1
- package/lib/check-site-id.js +2 -2
- package/lib/check-team.js +2 -2
- package/lib/check-theme.js +1 -1
- package/lib/check-user-id.js +3 -3
- package/lib/collect-routes.js +2 -2
- package/lib/collect-team.js +1 -1
- package/package.json +1 -1
- package/plugin/factory.js +12 -12
- package/waibuMpa/route/help/contact-form.js +1 -1
- package/waibuMpa/route/help/trouble-tickets/add.js +1 -1
- package/waibuMpa/route/help/trouble-tickets/details/@id.js +1 -1
- package/waibuMpa/route/my-stuff/profile/edit.js +1 -1
- package/waibuMpa/route/my-stuff/reset-api-key.js +1 -1
- package/waibuMpa/route/signin.js +1 -1
- package/waibuMpa/route/signout.js +1 -1
- package/waibuMpa/route/user/forgot-password/@fpl.js +2 -2
- package/waibuMpa/route/user/forgot-password.js +1 -1
- package/waibuRestApi/route/my-stuff/profile/update.js +1 -1
- package/waibuSocketIo/middleware/server/auth.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const doboBeforeRecordCreate = {
|
|
2
2
|
level: 1000,
|
|
3
3
|
handler: async function (body, options = {}) {
|
|
4
|
-
const { get, isEmpty } = this.
|
|
4
|
+
const { get, isEmpty } = this.lib._
|
|
5
5
|
const user = get(options, 'req.user')
|
|
6
6
|
if (user) {
|
|
7
7
|
if (isEmpty(body.firstName)) body.firstName = user.firstName
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
async function doboSumbaUserAfterRecordValidation (body, options) {
|
|
2
2
|
const { isBcrypt, hash } = this.app.bajoExtra
|
|
3
|
-
const { has } = this.
|
|
3
|
+
const { has } = this.lib._
|
|
4
4
|
|
|
5
5
|
if (has(body, 'password') && !isBcrypt(body.password)) body.password = await hash(body.password, 'bcrypt')
|
|
6
6
|
// if (has(body, 'token') && !isMd5(body.token)) body.token = await hash(body.token)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import passwordRule from '../../lib/password-rule.js'
|
|
2
2
|
|
|
3
3
|
async function doboSumbaUserBeforeRecordValidation (body, options = {}) {
|
|
4
|
-
const { set } = this.
|
|
4
|
+
const { set } = this.lib._
|
|
5
5
|
const password = await passwordRule.call(this, options.req)
|
|
6
6
|
const rule = { password }
|
|
7
7
|
set(options, 'validation.params.rule', rule)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const useAdmin = ['waibuAdmin']
|
|
2
2
|
|
|
3
3
|
export async function rebuildFilter (model, filter, req) {
|
|
4
|
-
const { isEmpty, map, find, get } = this.
|
|
4
|
+
const { isEmpty, map, find, get } = this.lib._
|
|
5
5
|
const { hasColumn } = this
|
|
6
6
|
filter.query = filter.query ?? {}
|
|
7
7
|
const hasSiteId = await hasColumn('siteId', model)
|
package/dobo/feature/lat-lng.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import latLngHook from '../../lib/lat-lng-hook.js'
|
|
2
2
|
|
|
3
3
|
async function latLng (opts = {}) {
|
|
4
|
-
const { merge } = this.
|
|
4
|
+
const { merge } = this.lib._
|
|
5
5
|
opts.fieldNameLat = opts.fieldNameLat ?? 'lat'
|
|
6
6
|
opts.fieldNameLng = opts.fieldNameLng ?? 'lng'
|
|
7
7
|
opts.scale = opts.scale ?? 5
|
package/dobo/feature/slug.js
CHANGED
|
@@ -2,7 +2,7 @@ import slug from 'slug'
|
|
|
2
2
|
|
|
3
3
|
async function autoInc ({ schema, body, opts }) {
|
|
4
4
|
const { recordFind } = this.app.dobo
|
|
5
|
-
const { set, last } = this.
|
|
5
|
+
const { set, last } = this.lib._
|
|
6
6
|
const query = set({}, opts.fieldName, { $regex: new RegExp('^' + body[opts.fieldName]) })
|
|
7
7
|
const sort = set({}, opts.fieldName, -1)
|
|
8
8
|
const options = { noHook: true, skipCache: true, thrownNotFound: false }
|
|
@@ -40,7 +40,7 @@ async function mainFn (opts = {}) {
|
|
|
40
40
|
hook: {
|
|
41
41
|
beforeCreate: async function ({ schema, body }) {
|
|
42
42
|
const { error } = this.app.bajo
|
|
43
|
-
const { isEmpty, isString } = this.
|
|
43
|
+
const { isEmpty, isString } = this.lib._
|
|
44
44
|
if (isEmpty(body[opts.fieldName])) {
|
|
45
45
|
if (isString(opts.fieldSource)) opts.fieldSource = [opts.fieldSource]
|
|
46
46
|
const source = []
|
package/lib/check-iconset.js
CHANGED
package/lib/check-site-id.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
async function mergeSetting (req) {
|
|
2
2
|
const { defaultsDeep, parseObject } = this.app.bajo
|
|
3
|
-
const { trim, get, filter } = this.
|
|
3
|
+
const { trim, get, filter } = this.lib._
|
|
4
4
|
const { recordFind, recordGet } = this.app.dobo
|
|
5
5
|
const defSetting = {}
|
|
6
6
|
const nsSetting = {}
|
|
@@ -30,7 +30,7 @@ async function mergeSetting (req) {
|
|
|
30
30
|
const omitted = ['status']
|
|
31
31
|
|
|
32
32
|
async function checkSiteId (req, reply) {
|
|
33
|
-
const { omit } = this.
|
|
33
|
+
const { omit } = this.lib._
|
|
34
34
|
const { recordFind } = this.app.dobo
|
|
35
35
|
|
|
36
36
|
if (!this.config.multiSite) {
|
package/lib/check-team.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pathsToCheck } from './check-user-id.js'
|
|
2
2
|
|
|
3
3
|
async function mergeTeam (req) {
|
|
4
|
-
const { map, pick } = this.
|
|
4
|
+
const { map, pick } = this.lib._
|
|
5
5
|
const { recordFindAll } = this.app.dobo
|
|
6
6
|
req.user.teams = []
|
|
7
7
|
const query = { userId: req.user.id, siteId: req.site.id }
|
|
@@ -15,7 +15,7 @@ async function mergeTeam (req) {
|
|
|
15
15
|
|
|
16
16
|
async function checkTeam (req, reply, source) {
|
|
17
17
|
if (!req.user) return
|
|
18
|
-
const { map } = this.
|
|
18
|
+
const { map } = this.lib._
|
|
19
19
|
await mergeTeam.call(this, req)
|
|
20
20
|
const paths = pathsToCheck.call(this, req, true)
|
|
21
21
|
const teams = map(req.user.teams, 'alias')
|
package/lib/check-theme.js
CHANGED
package/lib/check-user-id.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function pathsToCheck (req, withHome) {
|
|
2
|
-
const { uniq, without } = this.
|
|
2
|
+
const { uniq, without } = this.lib._
|
|
3
3
|
const checks = uniq(without([req.routeOptions.url, req.url], undefined, null))
|
|
4
4
|
/*
|
|
5
5
|
if (withHome) {
|
|
@@ -12,7 +12,7 @@ export function pathsToCheck (req, withHome) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async function setUser (req) {
|
|
15
|
-
const { get } = this.
|
|
15
|
+
const { get } = this.lib._
|
|
16
16
|
const id = get(req, 'session.user.id')
|
|
17
17
|
if (!id) return
|
|
18
18
|
try {
|
|
@@ -29,7 +29,7 @@ async function mergeSetting (req) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
async function checkUserId (req, reply, source) {
|
|
32
|
-
const { isEmpty, camelCase, get } = this.
|
|
32
|
+
const { isEmpty, camelCase, get } = this.lib._
|
|
33
33
|
const { routePath } = this.app.waibu
|
|
34
34
|
|
|
35
35
|
const webApp = get(req, 'routeOptions.config.webApp', 'waibu')
|
package/lib/collect-routes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export async function collect ({ type = '', handler, container, file, ns, dir }) {
|
|
2
2
|
const { readConfig } = this.app.bajo
|
|
3
3
|
const { routePath, routePathHandlers } = this.app.waibu
|
|
4
|
-
const { camelCase, find, isString, isEmpty } = this.
|
|
4
|
+
const { camelCase, find, isString, isEmpty } = this.lib._
|
|
5
5
|
const items = await readConfig(file, { ignoreError: true })
|
|
6
6
|
|
|
7
7
|
for (let item of items) {
|
|
@@ -23,7 +23,7 @@ export async function collect ({ type = '', handler, container, file, ns, dir })
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function handler (item) {
|
|
26
|
-
const { isString } = this.
|
|
26
|
+
const { isString } = this.lib._
|
|
27
27
|
for (const k of ['methods']) {
|
|
28
28
|
item[k] = item[k] ?? []
|
|
29
29
|
if (isString(item[k])) item[k] = item[k].split(',')
|
package/lib/collect-team.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { collect } from './collect-routes.js'
|
|
2
2
|
|
|
3
3
|
function handler (item) {
|
|
4
|
-
const { isString } = this.
|
|
4
|
+
const { isString } = this.lib._
|
|
5
5
|
for (const k of ['methods', 'teams', 'features']) {
|
|
6
6
|
item[k] = item[k] ?? []
|
|
7
7
|
if (isString(item[k])) item[k] = item[k].split(',')
|
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
async function getSetting (type, source) {
|
|
2
2
|
const { defaultsDeep } = this.app.bajo
|
|
3
|
-
const { get } = this.
|
|
3
|
+
const { get } = this.lib._
|
|
4
4
|
|
|
5
5
|
const setting = defaultsDeep(get(this.config, `auth.${source}.${type}`, {}), get(this.config, `auth.common.${type}`, {}))
|
|
6
6
|
if (type === 'basic') setting.type = 'Basic'
|
|
@@ -8,7 +8,7 @@ async function getSetting (type, source) {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async function getToken (type, req, source) {
|
|
11
|
-
const { isEmpty } = this.
|
|
11
|
+
const { isEmpty } = this.lib._
|
|
12
12
|
|
|
13
13
|
const setting = await getSetting.call(this, type, source)
|
|
14
14
|
let token = req.headers[setting.headerKey.toLowerCase()]
|
|
@@ -113,7 +113,7 @@ async function factory (pkgName) {
|
|
|
113
113
|
|
|
114
114
|
hasColumn = async (name, model) => {
|
|
115
115
|
const { getInfo } = this.app.dobo
|
|
116
|
-
const { find } = this.
|
|
116
|
+
const { find } = this.lib._
|
|
117
117
|
const { schema } = getInfo(model)
|
|
118
118
|
|
|
119
119
|
const result = find(schema.properties, { name })
|
|
@@ -122,7 +122,7 @@ async function factory (pkgName) {
|
|
|
122
122
|
|
|
123
123
|
getUser = async (rec, safe = true) => {
|
|
124
124
|
const { recordGet } = this.app.dobo
|
|
125
|
-
const { omit, isPlainObject } = this.
|
|
125
|
+
const { omit, isPlainObject } = this.lib._
|
|
126
126
|
|
|
127
127
|
let user
|
|
128
128
|
if (isPlainObject(rec)) user = rec
|
|
@@ -149,9 +149,9 @@ async function factory (pkgName) {
|
|
|
149
149
|
|
|
150
150
|
createJwtFromUserRecord = async (rec) => {
|
|
151
151
|
const { importPkg } = this.app.bajo
|
|
152
|
-
const { dayjs } = this.
|
|
152
|
+
const { dayjs } = this.lib
|
|
153
153
|
const { hash } = this.app.bajoExtra
|
|
154
|
-
const { get, pick } = this.
|
|
154
|
+
const { get, pick } = this.lib._
|
|
155
155
|
|
|
156
156
|
const fastJwt = await importPkg('bajoExtra:fast-jwt')
|
|
157
157
|
const { createSigner } = fastJwt
|
|
@@ -208,10 +208,10 @@ async function factory (pkgName) {
|
|
|
208
208
|
verifyBasic = async (req, reply, source) => {
|
|
209
209
|
const { getUserFromUsernamePassword } = this
|
|
210
210
|
const { getUser } = this
|
|
211
|
-
const { isEmpty } = this.
|
|
211
|
+
const { isEmpty } = this.lib._
|
|
212
212
|
|
|
213
213
|
const setHeader = async (setting, reply) => {
|
|
214
|
-
const { isString } = this.
|
|
214
|
+
const { isString } = this.lib._
|
|
215
215
|
|
|
216
216
|
let header = setting.type
|
|
217
217
|
const exts = []
|
|
@@ -251,7 +251,7 @@ async function factory (pkgName) {
|
|
|
251
251
|
const { importPkg } = this.app.bajo
|
|
252
252
|
const { recordGet } = this.app.dobo
|
|
253
253
|
const { getUser } = this
|
|
254
|
-
const { isEmpty } = this.
|
|
254
|
+
const { isEmpty } = this.lib._
|
|
255
255
|
|
|
256
256
|
const fastJwt = await importPkg('bajoExtra:fast-jwt')
|
|
257
257
|
const { createVerifier } = fastJwt
|
|
@@ -277,7 +277,7 @@ async function factory (pkgName) {
|
|
|
277
277
|
|
|
278
278
|
checkPathsByTeam = ({ paths = [], method = 'GET', teams = [], guards = [] }) => {
|
|
279
279
|
const { includes } = this.app.bajo
|
|
280
|
-
const { outmatch } = this.
|
|
280
|
+
const { outmatch } = this.lib
|
|
281
281
|
|
|
282
282
|
for (const item of guards) {
|
|
283
283
|
const matchPath = outmatch(item.path)
|
|
@@ -294,7 +294,7 @@ async function factory (pkgName) {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
checkPathsByRoute = ({ paths = [], method = 'GET', guards = [] }) => {
|
|
297
|
-
const { outmatch } = this.
|
|
297
|
+
const { outmatch } = this.lib
|
|
298
298
|
|
|
299
299
|
for (const item of guards) {
|
|
300
300
|
const matchPath = outmatch(item.path)
|
|
@@ -308,7 +308,7 @@ async function factory (pkgName) {
|
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
checkPathsByGuard = ({ guards, paths }) => {
|
|
311
|
-
const { outmatch } = this.
|
|
311
|
+
const { outmatch } = this.lib
|
|
312
312
|
const matcher = outmatch(guards)
|
|
313
313
|
let guarded
|
|
314
314
|
for (const path of paths) {
|
|
@@ -2,7 +2,7 @@ const contactForm = {
|
|
|
2
2
|
method: ['GET', 'POST'],
|
|
3
3
|
handler: async function (req, reply) {
|
|
4
4
|
const { defaultsDeep } = this.app.bajo
|
|
5
|
-
const { pick } = this.
|
|
5
|
+
const { pick } = this.lib._
|
|
6
6
|
const { recordCreate, recordFind } = this.app.waibuDb
|
|
7
7
|
|
|
8
8
|
const def = req.user ? pick(req.user, ['firstName', 'lastName', 'email']) : {}
|
|
@@ -4,7 +4,7 @@ const add = {
|
|
|
4
4
|
method: ['GET', 'POST'],
|
|
5
5
|
handler: async function (req, reply) {
|
|
6
6
|
const { recordCreate, recordFind } = this.app.waibuDb
|
|
7
|
-
const { defaultsDeep } = this.
|
|
7
|
+
const { defaultsDeep } = this.lib._
|
|
8
8
|
const options = {}
|
|
9
9
|
const form = defaultsDeep(req.body, {})
|
|
10
10
|
let error
|
|
@@ -3,7 +3,7 @@ const model = 'SumbaTicketDetail'
|
|
|
3
3
|
const id = {
|
|
4
4
|
method: ['GET', 'POST'],
|
|
5
5
|
handler: async function (req, reply) {
|
|
6
|
-
const { cloneDeep } = this.
|
|
6
|
+
const { cloneDeep } = this.lib._
|
|
7
7
|
const { recordCreate, recordFind, getSchemaExt } = this.app.waibuDb
|
|
8
8
|
const { schema } = await getSchemaExt(model, 'list')
|
|
9
9
|
|
|
@@ -4,7 +4,7 @@ const profile = {
|
|
|
4
4
|
const { defaultsDeep } = this.app.bajo
|
|
5
5
|
// const { attachmentCopyUploaded } = this.app.dobo
|
|
6
6
|
const { recordUpdate, recordGet } = this.app.waibuDb
|
|
7
|
-
const { omit, pick } = this.
|
|
7
|
+
const { omit, pick } = this.lib._
|
|
8
8
|
const { hash } = this.app.bajoExtra
|
|
9
9
|
const resp = await recordGet({ model: 'SumbaUser', req, id: req.user.id, options: { forceNoHidden: true, noHook: true, noCache: true } })
|
|
10
10
|
let form = defaultsDeep(req.body, omit(resp.data, ['password']))
|
|
@@ -6,7 +6,7 @@ const resetApiKey = {
|
|
|
6
6
|
const { defaultsDeep, importPkg, generateId } = this.app.bajo
|
|
7
7
|
const { recordGet, recordUpdate } = this.app.dobo
|
|
8
8
|
const { hash } = this.app.bajoExtra
|
|
9
|
-
const delay = await importPkg('delay')
|
|
9
|
+
const delay = await importPkg('bajo:delay')
|
|
10
10
|
const bcrypt = await importPkg('bajoExtra:bcrypt')
|
|
11
11
|
const Joi = await importPkg('dobo:joi')
|
|
12
12
|
const form = defaultsDeep(req.body, { apiKey: await hash(req.user.salt) })
|
package/waibuMpa/route/signin.js
CHANGED
|
@@ -3,7 +3,7 @@ const signin = {
|
|
|
3
3
|
handler: async function (req, reply) {
|
|
4
4
|
const { getUserFromUsernamePassword } = this
|
|
5
5
|
const { runHook } = this.app.bajo
|
|
6
|
-
const { isEmpty, omit } = this.
|
|
6
|
+
const { isEmpty, omit } = this.lib._
|
|
7
7
|
const { getSessionId } = this.app.waibuMpa
|
|
8
8
|
|
|
9
9
|
let { username, password, referer } = req.body || {}
|
|
@@ -2,7 +2,7 @@ const signout = {
|
|
|
2
2
|
method: ['GET', 'POST'],
|
|
3
3
|
handler: async function (req, reply) {
|
|
4
4
|
const { runHook } = this.app.bajo
|
|
5
|
-
// const { isEmpty } = this.
|
|
5
|
+
// const { isEmpty } = this.lib._
|
|
6
6
|
const { getSessionId } = this.app.waibuMpa
|
|
7
7
|
|
|
8
8
|
let { referer } = req.body || {}
|
|
@@ -2,7 +2,7 @@ import passwordRule from '../../../../lib/password-rule.js'
|
|
|
2
2
|
const model = 'SumbaUser'
|
|
3
3
|
|
|
4
4
|
async function getUser (req, reply) {
|
|
5
|
-
const { dayjs } = this.
|
|
5
|
+
const { dayjs } = this.lib
|
|
6
6
|
const { recordFind } = this.app.waibuDb
|
|
7
7
|
const invalidFpl = 'sumba.template:/user/fpl-invalid.html'
|
|
8
8
|
if (Buffer.from(req.params.fpl, 'base64').toString('base64') !== req.params.fpl) return invalidFpl
|
|
@@ -20,7 +20,7 @@ const forgotPasswordLink = {
|
|
|
20
20
|
handler: async function (req, reply) {
|
|
21
21
|
const { sendMail } = this.app.waibu
|
|
22
22
|
const { defaultsDeep, importPkg } = this.app.bajo
|
|
23
|
-
const { isString } = this.
|
|
23
|
+
const { isString } = this.lib._
|
|
24
24
|
const { recordUpdate } = this.app.dobo
|
|
25
25
|
const Joi = await importPkg('dobo:joi')
|
|
26
26
|
|
|
@@ -6,7 +6,7 @@ const profile = {
|
|
|
6
6
|
if (!this.app.masohiMail) return reply.view('sumba.template:/user/forgot-password.html')
|
|
7
7
|
const { sendMail } = this.app.waibu
|
|
8
8
|
const { defaultsDeep } = this.app.bajo
|
|
9
|
-
const { dayjs } = this.
|
|
9
|
+
const { dayjs } = this.lib
|
|
10
10
|
const { recordFind } = this.app.dobo
|
|
11
11
|
const form = defaultsDeep(req.body, {})
|
|
12
12
|
let error
|
|
@@ -3,7 +3,7 @@ const hidden = ['password', 'token', 'siteId']
|
|
|
3
3
|
|
|
4
4
|
async function get ({ ctx }) {
|
|
5
5
|
const { recordUpdate } = this.app.waibuDb
|
|
6
|
-
const { omit } = this.
|
|
6
|
+
const { omit } = this.lib._
|
|
7
7
|
|
|
8
8
|
const { docSchemaModel } = this.app.waibuRestApi
|
|
9
9
|
const schema = await docSchemaModel({ model, method: 'update', ctx, options: { hidden, noId: true } })
|