sumba 2.15.0 → 2.15.1
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/dobo@before-get-record.js +2 -3
- package/extend/dobo/feature/slug.js +3 -3
- package/extend/waibuMpa/route/help/contact-form.js +2 -2
- package/extend/waibuMpa/route/help/trouble-tickets/add.js +2 -2
- package/extend/waibuMpa/route/help/trouble-tickets/details/@id.js +2 -2
- package/extend/waibuMpa/route/user/activation.js +3 -3
- package/extend/waibuMpa/route/user/forgot-password/@fpl.js +4 -5
- package/extend/waibuMpa/route/user/forgot-password.js +2 -3
- package/package.json +1 -1
- package/wiki/CHANGES.md +1 -0
|
@@ -9,9 +9,8 @@ export async function checker (modelName, id, options = {}) {
|
|
|
9
9
|
await rebuildFilter.call(this, modelName, filter, req)
|
|
10
10
|
if (filter.query.$and) filter.query.$and.push({ id })
|
|
11
11
|
else filter.query.id = id
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (rows.length === 0) throw this.app.dobo.error('recordNotFound%s%s', id, this.name, { statusCode: 404 })
|
|
12
|
+
const row = await model.findOneRecord(filter, { count: false })
|
|
13
|
+
if (!row) throw this.app.dobo.error('recordNotFound%s%s', id, this.name, { statusCode: 404 })
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
const doboBeforeGetRecord = {
|
|
@@ -5,9 +5,9 @@ async function autoInc (body, opts) {
|
|
|
5
5
|
const query = set({}, opts.fieldName, { $regex: new RegExp('^' + body[opts.fieldName]) })
|
|
6
6
|
const sort = set({}, opts.fieldName, -1)
|
|
7
7
|
const options = { noHook: true, skipCache: true, thrownNotFound: false }
|
|
8
|
-
const resp = await this.
|
|
9
|
-
if (resp
|
|
10
|
-
const rslugs = resp[
|
|
8
|
+
const resp = await this.findOneRecord({ query, sort }, options)
|
|
9
|
+
if (resp) return body[opts.fieldName]
|
|
10
|
+
const rslugs = resp[opts.fieldName].split('-')
|
|
11
11
|
const slugs = body[opts.fieldName].split('-')
|
|
12
12
|
let num
|
|
13
13
|
if (Number(last(rslugs)) && body[opts.fieldName] === rslugs.slice(0, rslugs.length - 1).join('-')) {
|
|
@@ -3,7 +3,7 @@ const contactForm = {
|
|
|
3
3
|
handler: async function (req, reply) {
|
|
4
4
|
const { defaultsDeep } = this.app.lib.aneka
|
|
5
5
|
const { pick } = this.app.lib._
|
|
6
|
-
const { createRecord,
|
|
6
|
+
const { createRecord, findAllRecord } = this.app.waibuDb
|
|
7
7
|
|
|
8
8
|
const def = req.user ? pick(req.user, ['firstName', 'lastName', 'email']) : {}
|
|
9
9
|
const form = defaultsDeep(req.body, def)
|
|
@@ -17,7 +17,7 @@ const contactForm = {
|
|
|
17
17
|
error = err
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
const cats = await
|
|
20
|
+
const cats = await findAllRecord({ model: 'SumbaContactFormCat', req, options: { sort: 'level:1+name:1', dataOnly: true } })
|
|
21
21
|
return await reply.view('sumba.template:/help/contact-form/form.html', { form, error, cats })
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -4,7 +4,7 @@ const add = {
|
|
|
4
4
|
method: ['GET', 'POST'],
|
|
5
5
|
handler: async function (req, reply) {
|
|
6
6
|
const { defaultsDeep } = this.app.lib.aneka
|
|
7
|
-
const { createRecord,
|
|
7
|
+
const { createRecord, findAllRecord } = this.app.waibuDb
|
|
8
8
|
const options = {}
|
|
9
9
|
const form = defaultsDeep(req.body, {})
|
|
10
10
|
let error
|
|
@@ -16,7 +16,7 @@ const add = {
|
|
|
16
16
|
error = err
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const cats = await
|
|
19
|
+
const cats = await findAllRecord({ model: 'SumbaTicketCat', req, options: { sort: 'level:1+name:1', dataOnly: true } })
|
|
20
20
|
return await reply.view('sumba.template:/help/trouble-tickets/add.html', { form, error, cats })
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -4,10 +4,10 @@ const id = {
|
|
|
4
4
|
method: ['GET', 'POST'],
|
|
5
5
|
handler: async function (req, reply) {
|
|
6
6
|
const { cloneDeep } = this.app.lib._
|
|
7
|
-
const { createRecord, findRecord, getSchemaExt } = this.app.waibuDb
|
|
7
|
+
const { createRecord, findOneRecord, findRecord, getSchemaExt } = this.app.waibuDb
|
|
8
8
|
const { schema } = await getSchemaExt(model, 'list')
|
|
9
9
|
|
|
10
|
-
const master =
|
|
10
|
+
const master = await findOneRecord({ model: 'SumbaTicket', req, options: { dataOnly: true, query: { id: req.params.id } } })
|
|
11
11
|
if (!master) throw this.error('_notFound')
|
|
12
12
|
const form = cloneDeep(req.body)
|
|
13
13
|
let error
|
|
@@ -8,10 +8,10 @@ const userActivation = {
|
|
|
8
8
|
if (req.method === 'POST') {
|
|
9
9
|
try {
|
|
10
10
|
const query = { status: 'UNVERIFIED', token: req.body.key }
|
|
11
|
-
const result = await model.
|
|
12
|
-
if (result
|
|
11
|
+
const result = await model.findOneRecord({ query })
|
|
12
|
+
if (result) throw this.error('validationError', { details: [{ field: 'key', error: 'invalidActivationKey' }] })
|
|
13
13
|
await model.transaction(async (trx) => {
|
|
14
|
-
await model.updateRecord(result
|
|
14
|
+
await model.updateRecord(result.id, { status: 'ACTIVE' }, { req, noValidation: true, noFlash: true, trx })
|
|
15
15
|
})
|
|
16
16
|
req.flash('notify', req.t('userActivated'))
|
|
17
17
|
return reply.redirectTo(this.config.redirect.signin, req)
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
1
|
async function getUser (req, reply) {
|
|
3
2
|
const { dayjs } = this.app.lib
|
|
4
|
-
const {
|
|
3
|
+
const { findOneRecord } = this.app.waibuDb
|
|
5
4
|
const invalidFpl = 'sumba.template:/user/fpl-invalid.html'
|
|
6
5
|
if (Buffer.from(req.params.fpl, 'base64').toString('base64') !== req.params.fpl) return invalidFpl
|
|
7
6
|
const fpToken = Buffer.from(req.params.fpl, 'base64').toString()
|
|
8
7
|
const [token, sec] = fpToken.split(':')
|
|
9
8
|
if (dayjs().unix() > Number(sec)) return invalidFpl
|
|
10
9
|
const query = { token, status: 'ACTIVE' }
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
return
|
|
10
|
+
const user = await findOneRecord({ model: 'SumbaUser', req, options: { query, dataOnly: true, noHook: true } })
|
|
11
|
+
if (user) return invalidFpl
|
|
12
|
+
return user
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
const forgotPasswordLink = {
|
|
@@ -11,9 +11,8 @@ const profile = {
|
|
|
11
11
|
if (req.method === 'POST') {
|
|
12
12
|
try {
|
|
13
13
|
const query = { status: 'ACTIVE', $or: [{ username: req.body.usernameEmail }, { email: req.body.usernameEmail }] }
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
const data = result[0]
|
|
14
|
+
const data = await model.findOneRecord({ query }, { dataOnly: true, noHook: true, forceNoHidden: true })
|
|
15
|
+
if (data) throw this.error('validationError', { details: [{ field: 'usernameEmail', error: 'unknownUsernameEmailOrInactive' }] })
|
|
17
16
|
const to = `${data.firstName} ${data.lastName} <${data.email}>`
|
|
18
17
|
const subject = req.t('forgotPasswordLink')
|
|
19
18
|
const options = { req, reply }
|
package/package.json
CHANGED