sumba 2.0.0 → 2.1.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/.github/FUNDING.yml +13 -0
- package/.github/workflows/repo-lockdown.yml +24 -0
- package/.jsdoc.conf.json +45 -0
- package/LICENSE +1 -1
- package/README.md +40 -7
- package/docs/Sumba.html +3 -0
- package/docs/data/search.json +1 -0
- package/docs/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/global.html +3 -0
- package/docs/index.html +3 -0
- package/docs/index.js.html +538 -0
- package/docs/scripts/core.js +726 -0
- package/docs/scripts/core.min.js +23 -0
- package/docs/scripts/resize.js +90 -0
- package/docs/scripts/search.js +265 -0
- package/docs/scripts/search.min.js +6 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/scripts/third-party/fuse.js +9 -0
- package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/scripts/third-party/hljs-original.js +5171 -0
- package/docs/scripts/third-party/hljs.js +1 -0
- package/docs/scripts/third-party/popper.js +5 -0
- package/docs/scripts/third-party/tippy.js +1 -0
- package/docs/scripts/third-party/tocbot.js +672 -0
- package/docs/scripts/third-party/tocbot.min.js +1 -0
- package/docs/static/bitcoin.jpeg +0 -0
- package/docs/static/home.md +25 -0
- package/docs/static/logo-ecosystem.png +0 -0
- package/docs/static/logo.png +0 -0
- package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/styles/clean-jsdoc-theme.min.css +1 -0
- package/extend/bajo/hook/{dobo.sumba-contact-form@after-record-create.js → dobo.sumba-contact-form@after-create-record.js} +3 -3
- package/extend/bajo/hook/{dobo.sumba-contact-form@before-record-create.js → dobo.sumba-contact-form@before-create-record.js} +3 -3
- package/extend/bajo/hook/{dobo.sumba-user@after-record-create.js → dobo.sumba-user@after-create-record.js} +3 -3
- package/extend/bajo/hook/dobo.sumba-user@after-record-validation.js +3 -3
- package/extend/bajo/hook/{dobo.sumba-user@after-record-update.js → dobo.sumba-user@after-update-record.js} +5 -5
- package/extend/bajo/hook/{dobo.sumba-user@before-record-create.js → dobo.sumba-user@before-create-record.js} +2 -2
- package/extend/bajo/hook/dobo.sumba-user@before-record-validation.js +3 -3
- package/extend/bajo/hook/{dobo.sumba-user@before-record-update.js → dobo.sumba-user@before-update-record.js} +2 -2
- package/extend/bajo/hook/dobo@before-count-record.js +8 -0
- package/extend/bajo/hook/{dobo@before-record-create.js → dobo@before-create-record.js} +6 -6
- package/extend/bajo/hook/dobo@before-find-one-record.js +8 -0
- package/extend/bajo/hook/{dobo@before-record-find.js → dobo@before-find-record.js} +10 -10
- package/extend/bajo/hook/dobo@before-get-record.js +23 -0
- package/extend/bajo/hook/dobo@before-remove-record.js +10 -0
- package/extend/bajo/hook/dobo@before-update-record.js +10 -0
- package/extend/bajo/hook/waibu-mpa.sumba@after-build-locals.js +0 -0
- package/extend/bajo/hook/waibu-mpa@pre-parsing.js +0 -0
- package/extend/bajo/hook/waibu-rest-api@pre-parsing.js +0 -0
- package/extend/bajo/hook/waibu-static@pre-parsing.js +0 -0
- package/extend/bajo/hook/waibu@after-app-boot.js +2 -2
- package/extend/bajo/hook/waibu@after-create-context.js +0 -0
- package/extend/bajo/hook/waibu@on-request.js +0 -0
- package/extend/bajo/intl/en-US.json +1 -0
- package/extend/bajo/intl/id.json +0 -0
- package/extend/bajoTemplate/layout/centered.html +0 -0
- package/extend/bajoTemplate/layout/default.html +0 -0
- package/extend/bajoTemplate/layout/error.html +0 -0
- package/extend/bajoTemplate/layout/info.html +0 -0
- package/extend/bajoTemplate/partial/403.html +0 -0
- package/extend/bajoTemplate/partial/_admin/reset-user-password.html +0 -0
- package/extend/bajoTemplate/partial/_mail/help-contact-form.html +0 -0
- package/extend/bajoTemplate/partial/_mail/help-contact-form.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/mystuff-change-password.html +0 -0
- package/extend/bajoTemplate/partial/_mail/mystuff-change-password.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/mystuff-reset-api-key.html +0 -0
- package/extend/bajoTemplate/partial/_mail/mystuff-reset-api-key.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-activation-success.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-activation-success.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-forgot-password-changed.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-forgot-password-changed.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-forgot-password-link.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-forgot-password-link.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-signup-success-active.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-signup-success-active.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-signup-success.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-signup-success.id.html +0 -0
- package/extend/bajoTemplate/partial/api-key-modal.html +0 -0
- package/extend/bajoTemplate/partial/app-launcher.html +0 -0
- package/extend/bajoTemplate/partial/help/contact-form/form.html +0 -0
- package/extend/bajoTemplate/partial/help/contact-form/success.html +0 -0
- package/extend/bajoTemplate/partial/help/trouble-tickets/add.html +0 -0
- package/extend/bajoTemplate/partial/help/trouble-tickets/details.html +0 -0
- package/extend/bajoTemplate/partial/help/trouble-tickets/list.html +0 -0
- package/extend/bajoTemplate/partial/layout/address.html +0 -0
- package/extend/bajoTemplate/partial/layout/breadcrumb.html +0 -0
- package/extend/bajoTemplate/partial/layout/footer.html +0 -0
- package/extend/bajoTemplate/partial/layout/more-info.html +0 -0
- package/extend/bajoTemplate/partial/layout/more-info.id.html +0 -0
- package/extend/bajoTemplate/partial/layout/navbar.html +0 -0
- package/extend/bajoTemplate/partial/layout/sidebar.html +0 -0
- package/extend/bajoTemplate/partial/layout/socmed.html +0 -0
- package/extend/bajoTemplate/partial/list-item/change-password.html +0 -0
- package/extend/bajoTemplate/partial/list-item/forgot-password.html +0 -0
- package/extend/bajoTemplate/partial/list-item/goto-home.html +0 -0
- package/extend/bajoTemplate/partial/list-item/member-links.html +0 -0
- package/extend/bajoTemplate/partial/list-item/oauth-signin.html +0 -0
- package/extend/bajoTemplate/partial/list-item/signin.html +0 -0
- package/extend/bajoTemplate/partial/list-item/signout.html +0 -0
- package/extend/bajoTemplate/partial/list-item/user-signup.html +0 -0
- package/extend/bajoTemplate/partial/list-item/your-profile.html +0 -0
- package/extend/bajoTemplate/partial/signin.html +0 -0
- package/extend/bajoTemplate/partial/signout.html +0 -0
- package/extend/bajoTemplate/partial/user/activation.html +0 -0
- package/extend/bajoTemplate/partial/user/forgot-password-nomail.id.md +0 -0
- package/extend/bajoTemplate/partial/user/forgot-password-nomail.md +0 -0
- package/extend/bajoTemplate/partial/user/forgot-password.html +0 -0
- package/extend/bajoTemplate/partial/user/fpl-invalid.html +0 -0
- package/extend/bajoTemplate/partial/user/fpl-invalid.id.md +0 -0
- package/extend/bajoTemplate/partial/user/fpl-invalid.md +0 -0
- package/extend/bajoTemplate/partial/user/fpl.html +0 -0
- package/extend/bajoTemplate/partial/user/signup/form.html +0 -0
- package/extend/bajoTemplate/partial/user/signup/success-mail.id.md +0 -0
- package/extend/bajoTemplate/partial/user/signup/success-mail.md +0 -0
- package/extend/bajoTemplate/partial/user/signup/success-nomail.id.md +0 -0
- package/extend/bajoTemplate/partial/user/signup/success-nomail.md +0 -0
- package/extend/bajoTemplate/partial/user/signup/success.html +0 -0
- package/extend/bajoTemplate/partial/your-stuff/change-password.html +0 -0
- package/extend/bajoTemplate/partial/your-stuff/profile/edit.html +0 -0
- package/extend/bajoTemplate/partial/your-stuff/profile/view.html +0 -0
- package/extend/bajoTemplate/partial/your-stuff/reset-api-key.html +0 -0
- package/extend/bajoTemplate/template/403.html +0 -0
- package/extend/bajoTemplate/template/_admin/reset-user-password.html +0 -0
- package/extend/bajoTemplate/template/_mail/help-contact-form.html +0 -0
- package/extend/bajoTemplate/template/_mail/mystuff-change-password.html +0 -0
- package/extend/bajoTemplate/template/_mail/mystuff-reset-api-key.html +0 -0
- package/extend/bajoTemplate/template/_mail/user-activation-success.html +0 -0
- package/extend/bajoTemplate/template/_mail/user-forgot-password-changed.html +0 -0
- package/extend/bajoTemplate/template/_mail/user-forgot-password-link.html +0 -0
- package/extend/bajoTemplate/template/_mail/user-signup-success-active.html +0 -0
- package/extend/bajoTemplate/template/_mail/user-signup-success.html +0 -0
- package/extend/bajoTemplate/template/help/contact-form/form.html +0 -0
- package/extend/bajoTemplate/template/help/contact-form/success.html +0 -0
- package/extend/bajoTemplate/template/help/trouble-tickets/add.html +0 -0
- package/extend/bajoTemplate/template/help/trouble-tickets/details.html +0 -0
- package/extend/bajoTemplate/template/help/trouble-tickets/list.html +0 -0
- package/extend/bajoTemplate/template/info/about-us.md +0 -0
- package/extend/bajoTemplate/template/info/cookie-policy.md +0 -0
- package/extend/bajoTemplate/template/info/privacy.md +0 -0
- package/extend/bajoTemplate/template/info/terms-conditions.md +0 -0
- package/extend/bajoTemplate/template/signin.html +0 -0
- package/extend/bajoTemplate/template/signout.html +0 -0
- package/extend/bajoTemplate/template/user/activation.html +0 -0
- package/extend/bajoTemplate/template/user/forgot-password.html +0 -0
- package/extend/bajoTemplate/template/user/fpl-invalid.html +0 -0
- package/extend/bajoTemplate/template/user/fpl.html +0 -0
- package/extend/bajoTemplate/template/user/signup/form.html +0 -0
- package/extend/bajoTemplate/template/user/signup/success.html +0 -0
- package/extend/bajoTemplate/template/your-stuff/change-password.html +0 -0
- package/extend/bajoTemplate/template/your-stuff/profile/edit.html +0 -0
- package/extend/bajoTemplate/template/your-stuff/profile/view.html +0 -0
- package/extend/bajoTemplate/template/your-stuff/reset-api-key.html +0 -0
- package/extend/dobo/feature/address.js +1 -1
- package/extend/dobo/feature/category.js +0 -0
- package/extend/dobo/feature/country.js +1 -1
- package/extend/dobo/feature/email.js +0 -0
- package/extend/dobo/feature/lat-lng.js +3 -3
- package/extend/dobo/feature/lat.js +2 -2
- package/extend/dobo/feature/lng.js +2 -2
- package/extend/dobo/feature/person-in-charge.js +0 -0
- package/extend/dobo/feature/phone.js +0 -0
- package/extend/dobo/feature/site-id.js +3 -3
- package/extend/dobo/feature/slug.js +7 -8
- package/extend/dobo/feature/social.js +0 -0
- package/extend/dobo/feature/status.js +2 -2
- package/extend/dobo/feature/team-id.js +3 -3
- package/extend/dobo/feature/ts.js +0 -0
- package/extend/dobo/feature/url.js +6 -6
- package/extend/dobo/feature/user-id.js +5 -5
- package/extend/dobo/fixture/contact-form-cat.json +0 -0
- package/extend/dobo/fixture/site.json +0 -4
- package/extend/dobo/fixture/team-user.json +0 -0
- package/extend/dobo/fixture/team.json +2 -1
- package/extend/dobo/fixture/ticket-cat.json +0 -0
- package/extend/dobo/fixture/user.json +0 -0
- package/extend/dobo/model/contact-form-cat.json +3 -0
- package/extend/dobo/model/contact-form.json +16 -0
- package/extend/dobo/model/download.json +19 -0
- package/extend/dobo/model/site-setting.json +8 -0
- package/extend/dobo/{schema → model}/site.json +4 -8
- package/extend/dobo/{schema → model}/team-user.json +5 -10
- package/extend/dobo/model/team.json +15 -0
- package/extend/dobo/model/ticket-cat.json +3 -0
- package/extend/dobo/model/ticket-detail.json +7 -0
- package/extend/dobo/model/ticket.json +18 -0
- package/extend/dobo/{schema → model}/user.json +14 -11
- package/extend/masohiSocketIo/middleware/server/auth.js +1 -1
- package/extend/sumba/route/anonymous.json +0 -0
- package/extend/sumba/route/secure.json +0 -0
- package/extend/waibuBootstrap/theme/component/factory/nav-dropdown-user.js +5 -5
- package/extend/waibuDb/schema/contact-form-cat.json +0 -0
- package/extend/waibuDb/schema/contact-form.json +0 -0
- package/extend/waibuDb/schema/download.js +1 -1
- package/extend/waibuDb/schema/site.json +2 -2
- package/extend/waibuDb/schema/team-user.js +2 -2
- package/extend/waibuDb/schema/team.json +0 -0
- package/extend/waibuDb/schema/ticket-cat.json +0 -0
- package/extend/waibuDb/schema/user.json +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/contact-form/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/contact-form-cat/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/download/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/reset-user-password.js +5 -6
- package/extend/waibuMpa/extend/waibuAdmin/route/session/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/site.js +25 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/team/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/team-user/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/ticket/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/ticket-cat/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/user/@action.js +0 -0
- package/extend/waibuMpa/route/access-token.js +1 -2
- package/extend/waibuMpa/route/help/contact-form.js +5 -5
- package/extend/waibuMpa/route/help/trouble-tickets/add.js +4 -4
- package/extend/waibuMpa/route/help/trouble-tickets/details/@id.js +5 -5
- package/extend/waibuMpa/route/help/trouble-tickets/list.js +2 -2
- package/extend/waibuMpa/route/info/@item.js +0 -0
- package/extend/waibuMpa/route/signin.js +0 -0
- package/extend/waibuMpa/route/signout.js +1 -14
- package/extend/waibuMpa/route/user/activation.js +4 -6
- package/extend/waibuMpa/route/user/forgot-password/@fpl.js +9 -10
- package/extend/waibuMpa/route/user/forgot-password.js +5 -7
- package/extend/waibuMpa/route/user/signup.js +4 -4
- package/extend/waibuMpa/route/your-stuff/change-password.js +5 -6
- package/extend/waibuMpa/route/your-stuff/download/@action.js +0 -0
- package/extend/waibuMpa/route/your-stuff/download/get.js +0 -0
- package/extend/waibuMpa/route/your-stuff/profile/edit.js +5 -5
- package/extend/waibuMpa/route/your-stuff/profile.js +2 -2
- package/extend/waibuMpa/route/your-stuff/reset-api-key.js +8 -9
- package/extend/waibuRestApi/route/info/get.js +2 -2
- package/extend/waibuRestApi/route/manage/team/model-builder.json +0 -0
- package/extend/waibuRestApi/route/manage/user/model-builder.json +0 -0
- package/extend/waibuRestApi/route/user/access-token/@type/create.js +0 -0
- package/extend/waibuRestApi/route/user/api-key/get.js +1 -2
- package/extend/waibuRestApi/route/your-stuff/api-key/get.js +1 -2
- package/extend/waibuRestApi/route/your-stuff/api-key/update.js +5 -6
- package/extend/waibuRestApi/route/your-stuff/change-password/update.js +2 -3
- package/extend/waibuRestApi/route/your-stuff/profile/get.js +2 -2
- package/extend/waibuRestApi/route/your-stuff/profile/update.js +3 -3
- package/extend/waibuSocketIo/middleware/server/auth.js +2 -3
- package/extend/waibuStatic/asset/user-profile.png +0 -0
- package/index.js +78 -54
- package/lib/check-iconset.js +4 -6
- package/lib/check-team.js +1 -1
- package/lib/check-theme.js +4 -7
- package/lib/check-user-id.js +4 -3
- package/lib/collect-redirects.js +0 -0
- package/lib/collect-routes.js +4 -4
- package/lib/collect-team.js +3 -3
- package/lib/lat-lng-hook.js +2 -2
- package/lib/password-rule.js +0 -0
- package/lib/reset-token.js +1 -1
- package/lib/token-schema.js +0 -0
- package/logo.png +0 -0
- package/package.json +41 -34
- package/wiki/CHANGES.md +6 -0
- package/wiki/CONFIG.md +2 -0
- package/wiki/CONTRIBUTING.md +5 -0
- package/wiki/DEV-GUIDE.md +1 -0
- package/wiki/ECOSYSTEM.md +28 -0
- package/wiki/GETTING-STARTED.md +1 -0
- package/wiki/USER-GUIDE.md +1 -0
- package/extend/bajo/hook/dobo@before-record-count.js +0 -8
- package/extend/bajo/hook/dobo@before-record-find-one.js +0 -8
- package/extend/bajo/hook/dobo@before-record-get.js +0 -23
- package/extend/bajo/hook/dobo@before-record-remove.js +0 -10
- package/extend/bajo/hook/dobo@before-record-update.js +0 -10
- package/extend/dobo/schema/contact-form-cat.json +0 -3
- package/extend/dobo/schema/contact-form.json +0 -20
- package/extend/dobo/schema/download.json +0 -24
- package/extend/dobo/schema/site-setting.json +0 -8
- package/extend/dobo/schema/team.json +0 -19
- package/extend/dobo/schema/ticket-cat.json +0 -3
- package/extend/dobo/schema/ticket-detail.json +0 -7
- package/extend/dobo/schema/ticket.json +0 -17
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
const model = 'SumbaUser'
|
|
2
|
-
|
|
3
1
|
const userActivation = {
|
|
4
2
|
method: ['GET', 'POST'],
|
|
5
3
|
handler: async function (req, reply) {
|
|
6
|
-
const { defaultsDeep } = this.lib.aneka
|
|
7
|
-
const { recordFind, recordUpdate } = this.app.dobo
|
|
4
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
8
5
|
const form = defaultsDeep(req.body, { key: req.query.key })
|
|
6
|
+
const model = this.app.dobo.getModel('SumbaUser')
|
|
9
7
|
let error
|
|
10
8
|
if (req.method === 'POST') {
|
|
11
9
|
try {
|
|
12
10
|
const query = { status: 'UNVERIFIED', token: req.body.key }
|
|
13
|
-
const result = await
|
|
11
|
+
const result = await model.findRecord({ query, limit: 1 })
|
|
14
12
|
if (result.length === 0) throw this.error('validationError', { details: [{ field: 'key', error: 'invalidActivationKey' }] })
|
|
15
|
-
await
|
|
13
|
+
await model.updateRecord(result[0].id, { status: 'ACTIVE' }, { req, noValidation: true, noFlash: true })
|
|
16
14
|
req.flash('notify', req.t('userActivated'))
|
|
17
15
|
return reply.redirectTo(this.config.redirect.signin, req)
|
|
18
16
|
} catch (err) {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import passwordRule from '../../../../../lib/password-rule.js'
|
|
2
|
-
const model = 'SumbaUser'
|
|
3
2
|
|
|
4
3
|
async function getUser (req, reply) {
|
|
5
|
-
const { dayjs } = this.lib
|
|
6
|
-
const {
|
|
4
|
+
const { dayjs } = this.app.lib
|
|
5
|
+
const { findRecord } = this.app.waibuDb
|
|
7
6
|
const invalidFpl = 'sumba.template:/user/fpl-invalid.html'
|
|
8
7
|
if (Buffer.from(req.params.fpl, 'base64').toString('base64') !== req.params.fpl) return invalidFpl
|
|
9
8
|
const fpToken = Buffer.from(req.params.fpl, 'base64').toString()
|
|
10
9
|
const [token, sec] = fpToken.split(':')
|
|
11
10
|
if (dayjs().unix() > Number(sec)) return invalidFpl
|
|
12
11
|
const query = { token, status: 'ACTIVE' }
|
|
13
|
-
const users = await
|
|
12
|
+
const users = await findRecord({ model: 'SumbaUser', req, options: { query, limit: 1, dataOnly: true, noHook: true } })
|
|
14
13
|
if (users.length === 0) return invalidFpl
|
|
15
14
|
return users[0]
|
|
16
15
|
}
|
|
@@ -19,10 +18,10 @@ const forgotPasswordLink = {
|
|
|
19
18
|
method: ['GET', 'POST'],
|
|
20
19
|
handler: async function (req, reply) {
|
|
21
20
|
const { sendMail } = this.app.waibu
|
|
22
|
-
const { defaultsDeep } = this.lib.aneka
|
|
21
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
23
22
|
const { importPkg } = this.app.bajo
|
|
24
|
-
const { isString } = this.lib._
|
|
25
|
-
const
|
|
23
|
+
const { isString } = this.app.lib._
|
|
24
|
+
const model = this.app.dobo.getModel('SumbaUser')
|
|
26
25
|
const Joi = await importPkg('dobo:joi')
|
|
27
26
|
|
|
28
27
|
const form = defaultsDeep(req.body, {})
|
|
@@ -40,15 +39,15 @@ const forgotPasswordLink = {
|
|
|
40
39
|
try {
|
|
41
40
|
await schema.validateAsync(req.body, this.app.dobo.config.validationParams)
|
|
42
41
|
} catch (err) {
|
|
43
|
-
throw this.error('validationError', { details: err.details, values: err.values, ns: this.
|
|
42
|
+
throw this.error('validationError', { details: err.details, values: err.values, ns: this.ns, statusCode: 422, code: 'DB_VALIDATION' })
|
|
44
43
|
}
|
|
45
|
-
await
|
|
44
|
+
await model.updateRecord(user.id, { password: req.body.newPassword }, { noFlash: true })
|
|
46
45
|
const to = `${user.firstName} ${user.lastName} <${user.email}>`
|
|
47
46
|
const subject = req.t('forgotPasswordChanged')
|
|
48
47
|
const options = { req, reply, tpl: '' }
|
|
49
48
|
await sendMail(
|
|
50
49
|
'sumba.template:/_mail/user-forgot-password-changed.html',
|
|
51
|
-
{ to, subject, data: user, options, source: this.
|
|
50
|
+
{ to, subject, data: user, options, source: this.ns }
|
|
52
51
|
)
|
|
53
52
|
req.flash('notify', req.t('passwordChangedReSignin'))
|
|
54
53
|
return reply.redirectTo(this.config.redirect.signin)
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
const model = 'SumbaUser'
|
|
2
|
-
|
|
3
1
|
const profile = {
|
|
4
2
|
method: ['GET', 'POST'],
|
|
5
3
|
handler: async function (req, reply) {
|
|
6
4
|
if (!this.app.masohiMail) return await reply.view('sumba.template:/user/forgot-password.html')
|
|
7
5
|
const { sendMail } = this.app.waibu
|
|
8
|
-
const { defaultsDeep } = this.lib.aneka
|
|
9
|
-
const { dayjs } = this.lib
|
|
10
|
-
const
|
|
6
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
7
|
+
const { dayjs } = this.app.lib
|
|
8
|
+
const model = this.app.dobo.getModel('SumbaUser')
|
|
11
9
|
const form = defaultsDeep(req.body, {})
|
|
12
10
|
let error
|
|
13
11
|
if (req.method === 'POST') {
|
|
14
12
|
try {
|
|
15
13
|
const query = { status: 'ACTIVE', $or: [{ username: req.body.usernameEmail }, { email: req.body.usernameEmail }] }
|
|
16
|
-
const result = await
|
|
14
|
+
const result = await model.findRecord({ query, limit: 1 }, { dataOnly: true, noHook: true, forceNoHidden: true })
|
|
17
15
|
if (result.length === 0) throw this.error('validationError', { details: [{ field: 'usernameEmail', error: 'unknownUsernameEmailOrInactive' }] })
|
|
18
16
|
const data = result[0]
|
|
19
17
|
const to = `${data.firstName} ${data.lastName} <${data.email}>`
|
|
@@ -24,7 +22,7 @@ const profile = {
|
|
|
24
22
|
data._meta = { hostHeader: req.headers.host }
|
|
25
23
|
await sendMail(
|
|
26
24
|
'sumba.template:/_mail/user-forgot-password-link.html',
|
|
27
|
-
{ to, subject, data, options, source: this.
|
|
25
|
+
{ to, subject, data, options, source: this.ns }
|
|
28
26
|
)
|
|
29
27
|
req.flash('notify', req.t('emailSent'))
|
|
30
28
|
return reply.redirectTo(this.config.redirect.signin)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const signup = {
|
|
2
2
|
method: ['GET', 'POST'],
|
|
3
3
|
handler: async function (req, reply) {
|
|
4
|
-
const { defaultsDeep } = this.lib.aneka
|
|
5
|
-
const { generateId } = this.app.
|
|
6
|
-
const {
|
|
4
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
5
|
+
const { generateId } = this.app.lib.aneka
|
|
6
|
+
const { createRecord } = this.app.waibuDb
|
|
7
7
|
|
|
8
8
|
const form = defaultsDeep(req.body, {})
|
|
9
9
|
let error
|
|
@@ -24,7 +24,7 @@ const signup = {
|
|
|
24
24
|
const validation = { ns: ['sumba', 'dobo'], fields, extFields }
|
|
25
25
|
req.body.token = generateId()
|
|
26
26
|
req.body.provider = 'local'
|
|
27
|
-
const { data } = await
|
|
27
|
+
const { data } = await createRecord({ model: 'SumbaUser', req, reply, options: { validation, noFlash: true, forceNoHidden: true } })
|
|
28
28
|
req.flash('notify', req.t('userCreated'))
|
|
29
29
|
return await reply.view('sumba.template:/user/signup/success.html', { form: req.body, data })
|
|
30
30
|
} catch (err) {
|
|
@@ -3,12 +3,11 @@ import passwordRule from '../../../../lib/password-rule.js'
|
|
|
3
3
|
const profile = {
|
|
4
4
|
method: ['GET', 'POST'],
|
|
5
5
|
handler: async function (req, reply) {
|
|
6
|
-
const { defaultsDeep } = this.lib.aneka
|
|
6
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
7
7
|
const { importPkg } = this.app.bajo
|
|
8
|
-
const { recordGet, recordUpdate } = this.app.dobo
|
|
9
8
|
const bcrypt = await importPkg('bajoExtra:bcrypt')
|
|
10
9
|
const Joi = await importPkg('dobo:joi')
|
|
11
|
-
const model = 'SumbaUser'
|
|
10
|
+
const model = this.app.dobo.getModel('SumbaUser')
|
|
12
11
|
const form = defaultsDeep(req.body, {})
|
|
13
12
|
let error
|
|
14
13
|
if (req.method === 'POST') {
|
|
@@ -22,12 +21,12 @@ const profile = {
|
|
|
22
21
|
try {
|
|
23
22
|
await schema.validateAsync(req.body, this.app.dobo.config.validationParams)
|
|
24
23
|
} catch (err) {
|
|
25
|
-
throw this.error('validationError', { details: err.details, values: err.values, ns: this.
|
|
24
|
+
throw this.error('validationError', { details: err.details, values: err.values, ns: this.ns, statusCode: 422, code: 'DB_VALIDATION' })
|
|
26
25
|
}
|
|
27
|
-
const rec = await
|
|
26
|
+
const rec = await model.getRecord(req.user.id, { forceNoHidden: true })
|
|
28
27
|
const verified = await bcrypt.compare(req.body.currentPassword, rec.password)
|
|
29
28
|
if (!verified) throw this.error('invalidCurrentPassword', { details: [{ field: 'currentPassword', error: 'invalidPassword' }], statusCode: 400 })
|
|
30
|
-
await
|
|
29
|
+
await model.updateRecord(req.user.id, { password: req.body.newPassword }, { req, reply, noFlash: true })
|
|
31
30
|
// signout and redirect to signin
|
|
32
31
|
req.session.userId = null
|
|
33
32
|
req.flash('notify', req.t('passwordChangedReSignin'))
|
|
File without changes
|
|
File without changes
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const profile = {
|
|
2
2
|
method: ['GET', 'POST'],
|
|
3
3
|
handler: async function (req, reply) {
|
|
4
|
-
const { defaultsDeep } = this.lib.aneka
|
|
4
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
5
5
|
// const { attachmentCopyUploaded } = this.app.dobo
|
|
6
|
-
const {
|
|
7
|
-
const { omit, pick } = this.lib._
|
|
6
|
+
const { updateRecord, getRecord } = this.app.waibuDb
|
|
7
|
+
const { omit, pick } = this.app.lib._
|
|
8
8
|
const { hash } = this.app.bajoExtra
|
|
9
|
-
const resp = await
|
|
9
|
+
const resp = await getRecord({ 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']))
|
|
11
11
|
form.token = await hash(form.token)
|
|
12
12
|
let error
|
|
@@ -14,7 +14,7 @@ const profile = {
|
|
|
14
14
|
try {
|
|
15
15
|
const body = pick(form, ['firstName', 'lastName', 'address1', 'address2', 'city', 'zipCode', 'provinceState', 'country', 'phone', 'website'])
|
|
16
16
|
const options = { noFlash: true, hidden: [], setField: 'profile', setFile: 'main.png' }
|
|
17
|
-
const resp = await
|
|
17
|
+
const resp = await updateRecord({ req, reply, model: 'SumbaUser', id: req.user.id, body, options })
|
|
18
18
|
form = resp.data
|
|
19
19
|
req.flash('notify', req.t('profileUpdated'))
|
|
20
20
|
return reply.redirectTo('sumba:/your-stuff/profile')
|
|
@@ -2,9 +2,9 @@ const profile = {
|
|
|
2
2
|
method: ['GET'],
|
|
3
3
|
handler: async function (req, reply) {
|
|
4
4
|
const { hash } = this.app.bajoExtra
|
|
5
|
-
const {
|
|
5
|
+
const { getRecord } = this.app.waibuDb
|
|
6
6
|
const options = { forceNoHidden: true, noHook: true, noCache: true, attachment: true, mimeType: true }
|
|
7
|
-
const resp = await
|
|
7
|
+
const resp = await getRecord({ model: 'SumbaUser', req, id: req.user.id, options })
|
|
8
8
|
const form = resp.data
|
|
9
9
|
form.token = await hash(form.salt)
|
|
10
10
|
return await reply.view('sumba.template:/your-stuff/profile/view.html', { form })
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
const model = 'SumbaUser'
|
|
2
|
-
|
|
3
1
|
const resetApiKey = {
|
|
4
2
|
method: ['GET', 'POST'],
|
|
5
3
|
handler: async function (req, reply) {
|
|
6
|
-
const { defaultsDeep } = this.lib.aneka
|
|
7
|
-
const { importPkg
|
|
8
|
-
const {
|
|
4
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
5
|
+
const { importPkg } = this.app.bajo
|
|
6
|
+
const { generateId } = this.app.lib.aneka
|
|
9
7
|
const { hash } = this.app.bajoExtra
|
|
10
8
|
const delay = await importPkg('bajo:delay')
|
|
11
9
|
const bcrypt = await importPkg('bajoExtra:bcrypt')
|
|
12
10
|
const Joi = await importPkg('dobo:joi')
|
|
13
11
|
const form = defaultsDeep(req.body, { apiKey: await hash(req.user.salt) })
|
|
12
|
+
const model = this.app.dobo.getModel('SumbaUser')
|
|
14
13
|
let error
|
|
15
14
|
if (req.method === 'POST') {
|
|
16
15
|
try {
|
|
@@ -20,12 +19,12 @@ const resetApiKey = {
|
|
|
20
19
|
try {
|
|
21
20
|
await schema.validateAsync(req.body, this.app.dobo.config.validationParams)
|
|
22
21
|
} catch (err) {
|
|
23
|
-
throw this.error('validationError', { details: err.details, values: err.values, ns: this.
|
|
22
|
+
throw this.error('validationError', { details: err.details, values: err.values, ns: this.ns, statusCode: 422, code: 'DB_VALIDATION' })
|
|
24
23
|
}
|
|
25
|
-
const rec = await
|
|
26
|
-
const verified = await bcrypt.compare(
|
|
24
|
+
const rec = await model.getRecord(req.user.id, { forceNoHidden: true })
|
|
25
|
+
const verified = await bcrypt.compare(form.password, rec.password)
|
|
27
26
|
if (!verified) throw this.error('validationError', { details: [{ field: 'password', error: 'invalidPassword' }], statusCode: 400 })
|
|
28
|
-
await
|
|
27
|
+
await model.updateRecord(req.user.id, { salt: generateId() }, { req, reply, noFlash: true, forceNoHidden: true })
|
|
29
28
|
await delay(2000) // ensure req.user cache is expired
|
|
30
29
|
req.flash('notify', req.t('resetApiKeySuccessfull'))
|
|
31
30
|
return reply.redirectTo('sumba:/your-stuff/profile')
|
|
@@ -2,13 +2,13 @@ const hidden = []
|
|
|
2
2
|
const model = 'SumbaSite'
|
|
3
3
|
|
|
4
4
|
async function get ({ ctx }) {
|
|
5
|
-
const {
|
|
5
|
+
const { getRecord } = this.app.waibuDb
|
|
6
6
|
const { docSchemaModel } = this.app.waibuRestApi
|
|
7
7
|
|
|
8
8
|
const schema = await docSchemaModel({ model, method: 'get', ctx, options: { hidden, noId: true } })
|
|
9
9
|
const handler = async function (req, reply, options) {
|
|
10
10
|
options.hidden = hidden
|
|
11
|
-
return await
|
|
11
|
+
return await getRecord({ model, req, reply, id: req.site.id, options })
|
|
12
12
|
}
|
|
13
13
|
return { schema, handler }
|
|
14
14
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -12,10 +12,9 @@ async function get ({ ctx }) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const handler = async function (req, reply, options) {
|
|
15
|
-
const { recordGet } = this.app.dobo
|
|
16
15
|
const { hash } = this.app.bajoExtra
|
|
17
16
|
|
|
18
|
-
const profile = await
|
|
17
|
+
const profile = await this.app.dobo.getModel('SumbaUser').getRecord(req.user.id)
|
|
19
18
|
return { data: { token: await hash(profile.password) } }
|
|
20
19
|
}
|
|
21
20
|
return { schema, handler }
|
|
@@ -2,10 +2,9 @@ import { response } from './update.js'
|
|
|
2
2
|
|
|
3
3
|
async function get ({ ctx }) {
|
|
4
4
|
const { hash } = this.app.bajoExtra
|
|
5
|
-
const { recordGet } = this.app.dobo
|
|
6
5
|
const schema = { response: await response.call(this) }
|
|
7
6
|
const handler = async function get (req, reply) {
|
|
8
|
-
const rec = await
|
|
7
|
+
const rec = await this.app.dobo.getModel('SumbaUser').getRecord(req.user.id, { forceNoHidden: true })
|
|
9
8
|
return { data: { token: await hash(rec.salt) } }
|
|
10
9
|
}
|
|
11
10
|
return { schema, handler }
|
|
@@ -19,22 +19,21 @@ export const body = {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const model = 'SumbaUser'
|
|
23
|
-
|
|
24
22
|
async function update ({ ctx }) {
|
|
25
|
-
const { importPkg
|
|
26
|
-
const {
|
|
23
|
+
const { importPkg } = this.app.bajo
|
|
24
|
+
const { generateId } = this.app.lib.aneka
|
|
27
25
|
const { hash } = this.app.bajoExtra
|
|
28
26
|
const bcrypt = await importPkg('bajoExtra:bcrypt')
|
|
27
|
+
const model = this.app.dobo.getModel('SumbaUser')
|
|
29
28
|
|
|
30
29
|
const schema = { body, response: await response.call(this) }
|
|
31
30
|
|
|
32
31
|
const handler = async function get (req, reply, options) {
|
|
33
|
-
const rec = await
|
|
32
|
+
const rec = await model.getRecord(req.user.id, { forceNoHidden: true })
|
|
34
33
|
const verified = await bcrypt.compare(req.body.password, rec.password)
|
|
35
34
|
if (!verified) throw this.error('invalidPassword', { details: [{ field: 'password', error: 'invalidPassword' }], statusCode: 400 })
|
|
36
35
|
const input = { salt: generateId() }
|
|
37
|
-
const resp = await
|
|
36
|
+
const resp = await model.updateRecord(req.user.id, input, { forceNoHidden: true })
|
|
38
37
|
return { data: { token: await hash(resp.salt) } }
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -25,7 +25,6 @@ const model = 'SumbaUser'
|
|
|
25
25
|
|
|
26
26
|
async function update ({ ctx }) {
|
|
27
27
|
const { importPkg } = this.app.bajo
|
|
28
|
-
const { recordGet, recordUpdate } = this.app.dobo
|
|
29
28
|
const bcrypt = await importPkg('bajoExtra:bcrypt')
|
|
30
29
|
|
|
31
30
|
const schema = {
|
|
@@ -40,11 +39,11 @@ async function update ({ ctx }) {
|
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
const handler = async function get (req, reply, options) {
|
|
43
|
-
const rec = await
|
|
42
|
+
const rec = await this.app.dobo.getModel(model).getRecord(req.user.id, { forceNoHidden: true })
|
|
44
43
|
const verified = await bcrypt.compare(req.body.currentPassword, rec.password)
|
|
45
44
|
if (!verified) throw this.error('invalidCurrentPassword', { details: [{ field: 'current', error: 'invalidPassword' }], statusCode: 400 })
|
|
46
45
|
const input = { password: req.body.password }
|
|
47
|
-
await
|
|
46
|
+
await this.app.dobo.getModel(model).updateRecord(req.user.id, input)
|
|
48
47
|
return {}
|
|
49
48
|
}
|
|
50
49
|
|
|
@@ -2,12 +2,12 @@ const model = 'SumbaUser'
|
|
|
2
2
|
const hidden = ['password', 'token', 'siteId', 'salt']
|
|
3
3
|
|
|
4
4
|
async function get ({ ctx }) {
|
|
5
|
-
const {
|
|
5
|
+
const { getRecord } = this.app.waibuDb
|
|
6
6
|
const { docSchemaModel } = this.app.waibuRestApi
|
|
7
7
|
const schema = await docSchemaModel({ model, method: 'get', ctx, options: { hidden, noId: true } })
|
|
8
8
|
const handler = async function get (req, reply, options) {
|
|
9
9
|
options.hidden = hidden
|
|
10
|
-
return await
|
|
10
|
+
return await getRecord({ model, req, reply, id: req.user.id, options })
|
|
11
11
|
}
|
|
12
12
|
return { schema, handler }
|
|
13
13
|
}
|
|
@@ -2,15 +2,15 @@ const model = 'SumbaUser'
|
|
|
2
2
|
const hidden = ['password', 'token', 'siteId']
|
|
3
3
|
|
|
4
4
|
async function get ({ ctx }) {
|
|
5
|
-
const {
|
|
6
|
-
const { omit } = this.lib._
|
|
5
|
+
const { updateRecord } = this.app.waibuDb
|
|
6
|
+
const { omit } = this.app.lib._
|
|
7
7
|
|
|
8
8
|
const { docSchemaModel } = this.app.waibuRestApi
|
|
9
9
|
const schema = await docSchemaModel({ model, method: 'update', ctx, options: { hidden, noId: true } })
|
|
10
10
|
const handler = async function get (req, reply, options) {
|
|
11
11
|
options.hidden = hidden
|
|
12
12
|
const body = omit(req.body, ['username', 'status', ...hidden])
|
|
13
|
-
return await
|
|
13
|
+
return await updateRecord({ model, req, reply, id: req.user.id, body, options })
|
|
14
14
|
}
|
|
15
15
|
return { schema, handler }
|
|
16
16
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
level: 1,
|
|
3
3
|
handler: async function (socket) {
|
|
4
|
-
const { merge } = this.lib._
|
|
5
|
-
const { recordGet } = this.app.dobo
|
|
4
|
+
const { merge } = this.app.lib._
|
|
6
5
|
const { getSessionId } = this.app.waibuMpa
|
|
7
6
|
|
|
8
7
|
if (socket.handshake) {
|
|
9
8
|
const sessionId = await getSessionId(socket.request.headers.cookie)
|
|
10
|
-
const resp = await
|
|
9
|
+
const resp = await this.app.dobo.getModel('WbmpaSession').getRecord(sessionId, { noHook: true, thrownNotFound: false })
|
|
11
10
|
if (resp) {
|
|
12
11
|
const session = JSON.parse(resp.session) ?? {}
|
|
13
12
|
socket.session = merge({}, session.user, { sessionId, authMethod: 'cookie' })
|
|
File without changes
|