sumba 2.0.1 → 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 +0 -0
- package/.github/workflows/repo-lockdown.yml +0 -0
- package/.jsdoc.conf.json +0 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/docs/Sumba.html +0 -0
- package/docs/data/search.json +0 -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 +0 -0
- package/docs/index.html +0 -0
- package/docs/index.js.html +40 -28
- package/docs/scripts/core.js +0 -0
- package/docs/scripts/core.min.js +0 -0
- package/docs/scripts/resize.js +0 -0
- package/docs/scripts/search.js +0 -0
- package/docs/scripts/search.min.js +0 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +0 -0
- package/docs/scripts/third-party/fuse.js +0 -0
- package/docs/scripts/third-party/hljs-line-num-original.js +0 -0
- package/docs/scripts/third-party/hljs-line-num.js +0 -0
- package/docs/scripts/third-party/hljs-original.js +0 -0
- package/docs/scripts/third-party/hljs.js +0 -0
- package/docs/scripts/third-party/popper.js +0 -0
- package/docs/scripts/third-party/tippy.js +0 -0
- package/docs/scripts/third-party/tocbot.js +0 -0
- package/docs/scripts/third-party/tocbot.min.js +0 -0
- package/docs/static/bitcoin.jpeg +0 -0
- package/docs/static/home.md +0 -0
- package/docs/static/logo-ecosystem.png +0 -0
- package/docs/static/logo.png +0 -0
- package/docs/styles/clean-jsdoc-theme-base.css +0 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +0 -0
- package/docs/styles/clean-jsdoc-theme-light.css +0 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -0
- package/docs/styles/clean-jsdoc-theme.min.css +0 -0
- package/extend/bajo/hook/{dobo.sumba-contact-form@after-record-create.js → dobo.sumba-contact-form@after-create-record.js} +2 -2
- package/extend/bajo/hook/{dobo.sumba-contact-form@before-record-create.js → dobo.sumba-contact-form@before-create-record.js} +2 -2
- package/extend/bajo/hook/{dobo.sumba-user@after-record-create.js → dobo.sumba-user@after-create-record.js} +2 -2
- package/extend/bajo/hook/dobo.sumba-user@after-record-validation.js +2 -2
- package/extend/bajo/hook/{dobo.sumba-user@after-record-update.js → dobo.sumba-user@after-update-record.js} +2 -2
- 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 +2 -2
- 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} +5 -5
- 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} +9 -9
- 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 +0 -0
- 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 +2 -2
- 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 +5 -6
- package/extend/dobo/feature/social.js +0 -0
- package/extend/dobo/feature/status.js +1 -1
- package/extend/dobo/feature/team-id.js +3 -3
- package/extend/dobo/feature/ts.js +0 -0
- package/extend/dobo/feature/url.js +5 -5
- 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 +0 -0
- 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 +4 -4
- 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 +3 -4
- 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 +3 -3
- package/extend/waibuMpa/route/help/trouble-tickets/add.js +3 -3
- package/extend/waibuMpa/route/help/trouble-tickets/details/@id.js +4 -4
- 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 +3 -5
- package/extend/waibuMpa/route/user/forgot-password/@fpl.js +4 -5
- package/extend/waibuMpa/route/user/forgot-password.js +2 -4
- package/extend/waibuMpa/route/user/signup.js +3 -3
- package/extend/waibuMpa/route/your-stuff/change-password.js +3 -4
- 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 +3 -3
- package/extend/waibuMpa/route/your-stuff/profile.js +2 -2
- package/extend/waibuMpa/route/your-stuff/reset-api-key.js +6 -7
- 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 +2 -2
- package/extend/waibuSocketIo/middleware/server/auth.js +1 -2
- package/extend/waibuStatic/asset/user-profile.png +0 -0
- package/index.js +39 -30
- package/lib/check-iconset.js +3 -5
- package/lib/check-team.js +0 -0
- package/lib/check-theme.js +3 -6
- package/lib/check-user-id.js +1 -0
- package/lib/collect-redirects.js +0 -0
- package/lib/collect-routes.js +0 -0
- package/lib/collect-team.js +0 -0
- package/lib/lat-lng-hook.js +0 -0
- 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 +6 -4
- package/wiki/CHANGES.md +6 -0
- package/wiki/CONFIG.md +0 -0
- package/wiki/CONTRIBUTING.md +0 -0
- package/wiki/DEV-GUIDE.md +0 -0
- package/wiki/ECOSYSTEM.md +0 -0
- package/wiki/GETTING-STARTED.md +0 -0
- package/wiki/USER-GUIDE.md +0 -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
package/.github/FUNDING.yml
CHANGED
|
File without changes
|
|
File without changes
|
package/.jsdoc.conf.json
CHANGED
|
File without changes
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/docs/Sumba.html
CHANGED
|
File without changes
|
package/docs/data/search.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/global.html
CHANGED
|
File without changes
|
package/docs/index.html
CHANGED
|
File without changes
|
package/docs/index.js.html
CHANGED
|
@@ -16,9 +16,9 @@ async function factory (pkgName) {
|
|
|
16
16
|
*
|
|
17
17
|
* @class
|
|
18
18
|
*/
|
|
19
|
-
class Sumba extends this.app.
|
|
19
|
+
class Sumba extends this.app.baseClass.Base {
|
|
20
20
|
static alias = 'sumba'
|
|
21
|
-
static dependencies = ['bajo-extra', 'bajo-common-db', 'bajo-config']
|
|
21
|
+
static dependencies = ['bajo-extra', 'bajo-common-db', 'bajo-config', 'bajo-markdown']
|
|
22
22
|
|
|
23
23
|
constructor () {
|
|
24
24
|
super(pkgName, me.app)
|
|
@@ -195,37 +195,41 @@ async function factory (pkgName) {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
getUser = async (rec, safe = true) => {
|
|
198
|
-
const { recordGet } = this.app.dobo
|
|
199
198
|
const { omit, isPlainObject } = this.app.lib._
|
|
200
199
|
let user
|
|
201
200
|
if (isPlainObject(rec)) user = rec
|
|
202
|
-
else
|
|
201
|
+
else {
|
|
202
|
+
const mdl = this.app.dobo.getModel('SumbaUser')
|
|
203
|
+
user = await mdl.getRecord(rec, { noHook: true, throwNotFound: false })
|
|
204
|
+
}
|
|
205
|
+
if (!user) return null
|
|
203
206
|
return safe ? omit(user, this.unsafeUserFields) : user
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
mergeTeam = async (user, site) => {
|
|
207
210
|
if (!user) return
|
|
208
211
|
const { map, pick } = this.app.lib._
|
|
209
|
-
const { recordFindAll } = this.app.dobo
|
|
210
212
|
user.teams = []
|
|
211
213
|
const query = { userId: user.id, siteId: site.id }
|
|
212
|
-
|
|
214
|
+
let mdl = this.app.dobo.getModel('SumbaTeamUser')
|
|
215
|
+
const userTeam = await mdl.findAllRecord({ query })
|
|
213
216
|
if (userTeam.length === 0) return
|
|
214
217
|
delete query.userId
|
|
215
|
-
query.id = { $in: map(userTeam, 'id')
|
|
216
|
-
|
|
218
|
+
query.id = { $in: map(userTeam, 'id') }
|
|
219
|
+
query.status = 'ENABLED'
|
|
220
|
+
mdl = this.app.dobo.getModel('SumbaTeam')
|
|
221
|
+
const team = await mdl.findAllRecord({ query })
|
|
217
222
|
if (team.length > 0) user.teams.push(...map(team, t => pick(t, ['id', 'alias'])))
|
|
218
223
|
}
|
|
219
224
|
|
|
220
225
|
getUserFromUsernamePassword = async (username = '', password = '', req) => {
|
|
221
226
|
const { importPkg } = this.app.bajo
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
await validate({ username, password }, model, { ns: ['sumba', 'dobo'], fields: ['username', 'password'] })
|
|
227
|
+
const model = this.app.dobo.getModel('SumbaUser')
|
|
228
|
+
await model.validate({ username, password }, null, { partial: true, ns: ['sumba', 'dobo'], fields: ['username', 'password'] })
|
|
225
229
|
const bcrypt = await importPkg('bajoExtra:bcrypt')
|
|
226
230
|
|
|
227
231
|
const query = { username, provider: 'local' }
|
|
228
|
-
const rows = await
|
|
232
|
+
const rows = await model.findRecord({ query }, { req, forceNoHidden: true, noHook: true })
|
|
229
233
|
if (rows.length === 0) throw this.error('validationError', { details: [{ field: 'username', error: 'Unknown username' }], statusCode: 401 })
|
|
230
234
|
const rec = rows[0]
|
|
231
235
|
if (rec.status !== 'ACTIVE') throw this.error('validationError', { details: ['User is inactive or temporarily disabled'], statusCode: 401 })
|
|
@@ -271,13 +275,12 @@ async function factory (pkgName) {
|
|
|
271
275
|
const { merge } = this.app.lib._
|
|
272
276
|
const { isMd5, hash } = this.app.bajoExtra
|
|
273
277
|
const { getUser } = this
|
|
274
|
-
const { recordFind } = this.app.dobo
|
|
275
278
|
|
|
276
279
|
let token = await this._getToken('apiKey', req, source)
|
|
277
280
|
if (!isMd5(token)) return false
|
|
278
281
|
token = await hash(token)
|
|
279
282
|
const query = { token }
|
|
280
|
-
const rows = await
|
|
283
|
+
const rows = await this.app.dobo.getModel('SumbaUser').findRecord({ query }, { req, noHook: true })
|
|
281
284
|
if (rows.length === 0) throw this.error('invalidKey', merge({ statusCode: 401 }, payload))
|
|
282
285
|
if (rows[0].status !== 'ACTIVE') throw this.error('userInactive', merge({ details: [{ field: 'status', error: 'inactive' }], statusCode: 401 }, payload))
|
|
283
286
|
req.user = await getUser(rows[0])
|
|
@@ -328,7 +331,6 @@ async function factory (pkgName) {
|
|
|
328
331
|
|
|
329
332
|
verifyJwt = async (req, reply, source, payload) => {
|
|
330
333
|
const { importPkg } = this.app.bajo
|
|
331
|
-
const { recordGet } = this.app.dobo
|
|
332
334
|
const { getUser } = this
|
|
333
335
|
const { isEmpty, merge } = this.app.lib._
|
|
334
336
|
|
|
@@ -344,7 +346,7 @@ async function factory (pkgName) {
|
|
|
344
346
|
const decoded = await verifier(token)
|
|
345
347
|
const id = decoded.payload.uid
|
|
346
348
|
try {
|
|
347
|
-
const rec = await
|
|
349
|
+
const rec = await this.app.dobo.getModel('SumbaUser').getRecord(id, { req, noHook: true })
|
|
348
350
|
if (!rec) throw this.error('invalidToken', { statusCode: 401 })
|
|
349
351
|
if (rec.status !== 'ACTIVE') throw this.error('userInactive', { details: [{ field: 'status', error: 'inactive' }], statusCode: 401 })
|
|
350
352
|
req.user = await getUser(rec)
|
|
@@ -399,14 +401,12 @@ async function factory (pkgName) {
|
|
|
399
401
|
|
|
400
402
|
getSite = async (hostname, useId) => {
|
|
401
403
|
const { omit } = this.app.lib._
|
|
402
|
-
const { recordFind } = this.app.dobo
|
|
403
404
|
const omitted = ['status']
|
|
404
405
|
|
|
405
406
|
const mergeSetting = async (site) => {
|
|
406
407
|
const { defaultsDeep } = this.app.lib.aneka
|
|
407
|
-
const { parseObject } = this.app.
|
|
408
|
+
const { parseObject } = this.app.lib
|
|
408
409
|
const { trim, get, filter } = this.app.lib._
|
|
409
|
-
const { recordFind, recordGet } = this.app.dobo
|
|
410
410
|
const defSetting = {}
|
|
411
411
|
const nsSetting = {}
|
|
412
412
|
const names = this.app.getAllNs()
|
|
@@ -414,7 +414,7 @@ async function factory (pkgName) {
|
|
|
414
414
|
ns: { $in: names },
|
|
415
415
|
siteId: site.id
|
|
416
416
|
}
|
|
417
|
-
const all = await
|
|
417
|
+
const all = await this.app.dobo.getModel('SumbaSiteSetting').findRecord({ query, limit: -1 })
|
|
418
418
|
for (const ns of names) {
|
|
419
419
|
nsSetting[ns] = {}
|
|
420
420
|
defSetting[ns] = get(this, `app.${ns}.config.siteSetting`, {})
|
|
@@ -429,14 +429,14 @@ async function factory (pkgName) {
|
|
|
429
429
|
}
|
|
430
430
|
site.setting = parseObject(defaultsDeep({}, nsSetting, defSetting))
|
|
431
431
|
// additional fields
|
|
432
|
-
const country = await
|
|
432
|
+
const country = await this.app.dobo.getModel('CdbCountry').getRecord(site.country, { noHook: true })
|
|
433
433
|
site.countryName = (country ?? {}).name ?? site.country
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
let site = {}
|
|
437
437
|
|
|
438
438
|
if (!this.config.multiSite) {
|
|
439
|
-
const resp = await
|
|
439
|
+
const resp = await this.app.dobo.getModel('SumbaSite').findRecord({ query: { alias: 'default' } }, { noHook: true })
|
|
440
440
|
site = omit(resp[0], omitted)
|
|
441
441
|
await mergeSetting(site)
|
|
442
442
|
return site
|
|
@@ -452,7 +452,7 @@ async function factory (pkgName) {
|
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
const filter = { query, limit: 1 }
|
|
455
|
-
const rows = await
|
|
455
|
+
const rows = await this.app.dobo.getModel('SumbaSite').findRecord(filter, { noHook: true })
|
|
456
456
|
if (rows.length === 0) throw this.error('unknownSite')
|
|
457
457
|
const row = omit(rows[0], omitted)
|
|
458
458
|
if (row.status !== 'ACTIVE') throw this.error('siteInactiveInfo')
|
|
@@ -461,6 +461,19 @@ async function factory (pkgName) {
|
|
|
461
461
|
return site
|
|
462
462
|
}
|
|
463
463
|
|
|
464
|
+
signout = async ({ req, reply, reason }) => {
|
|
465
|
+
const { runHook } = this.app.bajo
|
|
466
|
+
const { getSessionId } = this.app.waibuMpa
|
|
467
|
+
const sid = await getSessionId(req.headers.cookie)
|
|
468
|
+
req.session.userId = null
|
|
469
|
+
await runHook(`${this.ns}:afterSignout`, sid, req)
|
|
470
|
+
const { query, params } = req
|
|
471
|
+
// const url = !isEmpty(referer) ? referer : this.config.redirect.home
|
|
472
|
+
const url = this.config.redirect.afterSignout
|
|
473
|
+
req.flash('notify', req.t(reason ?? 'signoutSuccessfully'))
|
|
474
|
+
return reply.redirectTo(url, { query, params })
|
|
475
|
+
}
|
|
476
|
+
|
|
464
477
|
signin = async ({ user, req, reply }) => {
|
|
465
478
|
const { getSessionId } = this.app.waibuMpa
|
|
466
479
|
const { runHook } = this.app.bajo
|
|
@@ -479,7 +492,7 @@ async function factory (pkgName) {
|
|
|
479
492
|
}
|
|
480
493
|
|
|
481
494
|
generatePassword = (req) => {
|
|
482
|
-
const { generateId } = this.app.
|
|
495
|
+
const { generateId } = this.app.lib.aneka
|
|
483
496
|
const cfg = req ? req.site.setting.sumba.userPassword : this.config.siteSetting.userPassword
|
|
484
497
|
let passwd = generateId()
|
|
485
498
|
if (cfg.minLowercase) passwd += generateId({ pattern: 'abcdefghijklmnopqrstuvwxyz', length: cfg.minLowercase })
|
|
@@ -491,7 +504,7 @@ async function factory (pkgName) {
|
|
|
491
504
|
|
|
492
505
|
pushDownload = async ({ description, worker, data, source, req, file, type }) => {
|
|
493
506
|
const { getPlugin } = this.app.bajo
|
|
494
|
-
const {
|
|
507
|
+
const { createRecord } = getPlugin('waibuDb')
|
|
495
508
|
const { push } = getPlugin('bajoQueue')
|
|
496
509
|
description = description ?? file
|
|
497
510
|
const jobQueue = {
|
|
@@ -505,16 +518,15 @@ async function factory (pkgName) {
|
|
|
505
518
|
if (!type) type = path.extname(file)
|
|
506
519
|
if (type[0] === '.') type = type.slice(1)
|
|
507
520
|
const body = { file, description, jobQueue, type }
|
|
508
|
-
const rec = await
|
|
521
|
+
const rec = await createRecord({ model: 'SumbaDownload', body, req, options: { noFlash: true } })
|
|
509
522
|
jobQueue.payload.data.download = { id: rec.data.id, file }
|
|
510
523
|
await push(jobQueue)
|
|
511
524
|
}
|
|
512
525
|
|
|
513
526
|
getApiKeyFromUserId = async id => {
|
|
514
527
|
const { hash } = this.app.bajoExtra
|
|
515
|
-
const { recordGet } = this.app.dobo
|
|
516
528
|
const options = { forceNoHidden: true, noHook: true, noCache: true, attachment: true, mimeType: true }
|
|
517
|
-
const resp = await
|
|
529
|
+
const resp = await this.app.dobo.getModel('SumbaUser').getRecord(id, options)
|
|
518
530
|
return await hash(resp.salt)
|
|
519
531
|
}
|
|
520
532
|
}
|
package/docs/scripts/core.js
CHANGED
|
File without changes
|
package/docs/scripts/core.min.js
CHANGED
|
File without changes
|
package/docs/scripts/resize.js
CHANGED
|
File without changes
|
package/docs/scripts/search.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/static/bitcoin.jpeg
CHANGED
|
File without changes
|
package/docs/static/home.md
CHANGED
|
File without changes
|
|
File without changes
|
package/docs/static/logo.png
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function
|
|
1
|
+
async function afterCreateRecord (body, options = {}, rec) {
|
|
2
2
|
if (!options.req) return
|
|
3
3
|
if (!this.app.waibu) return
|
|
4
4
|
const { sendMail } = this.app.waibu
|
|
@@ -14,4 +14,4 @@ async function afterRecordCreate (body, options = {}, rec) {
|
|
|
14
14
|
)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export default
|
|
17
|
+
export default afterCreateRecord
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const beforeCreateRecord = {
|
|
2
2
|
level: 1000,
|
|
3
3
|
handler: async function (body, options = {}) {
|
|
4
4
|
const { get, isEmpty } = this.app.lib._
|
|
@@ -13,4 +13,4 @@ const doboBeforeRecordCreate = {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export default
|
|
16
|
+
export default beforeCreateRecord
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function
|
|
1
|
+
async function afterCreateRecord (body, rec, options = {}) {
|
|
2
2
|
if (!options.req) return
|
|
3
3
|
if (!this.app.waibu) return
|
|
4
4
|
const { sendMail } = this.app.waibu
|
|
@@ -11,4 +11,4 @@ async function afterRecordCreate (body, options = {}, rec) {
|
|
|
11
11
|
)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export default
|
|
14
|
+
export default afterCreateRecord
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function
|
|
1
|
+
async function afterRecordValidation (body, options) {
|
|
2
2
|
const { isBcrypt, hash } = this.app.bajoExtra
|
|
3
3
|
const { has } = this.app.lib._
|
|
4
4
|
|
|
@@ -6,4 +6,4 @@ async function doboSumbaUserAfterRecordValidation (body, options) {
|
|
|
6
6
|
// if (has(body, 'token') && !isMd5(body.token)) body.token = await hash(body.token)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export default afterRecordValidation
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function
|
|
1
|
+
async function afterUpdateRecord (id, body, rec, options = {}) {
|
|
2
2
|
if (!options.req) return
|
|
3
3
|
if (!this.app.waibu) return
|
|
4
4
|
const { data, oldData } = rec
|
|
@@ -27,4 +27,4 @@ async function afterRecordUpdate (id, body, options = {}, rec) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export default
|
|
30
|
+
export default afterUpdateRecord
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import resetToken from '../../../lib/reset-token.js'
|
|
2
2
|
|
|
3
|
-
async function
|
|
3
|
+
async function beforeCreateRecord (body, options = {}) {
|
|
4
4
|
const { token, salt } = await resetToken.call(this)
|
|
5
5
|
body.token = token
|
|
6
6
|
body.salt = salt
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export default beforeCreateRecord
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import passwordRule from '../../../lib/password-rule.js'
|
|
2
2
|
|
|
3
|
-
async function
|
|
3
|
+
async function beforeRecordValidation (body, options = {}) {
|
|
4
4
|
const { set } = this.app.lib._
|
|
5
5
|
const password = await passwordRule.call(this, options.req)
|
|
6
6
|
const rule = { password }
|
|
7
7
|
set(options, 'validation.params.rule', rule)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export default
|
|
10
|
+
export default beforeRecordValidation
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import resetToken from '../../../lib/reset-token.js'
|
|
2
2
|
|
|
3
|
-
async function
|
|
3
|
+
async function beforeUpdateRecord (id, body, options = {}) {
|
|
4
4
|
if (body.salt) {
|
|
5
5
|
const { token, salt } = await resetToken.call(this, body.salt)
|
|
6
6
|
body.token = token
|
|
@@ -8,4 +8,4 @@ async function beforeRecordUpdate (id, body, options = {}) {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export default
|
|
11
|
+
export default beforeUpdateRecord
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
const
|
|
1
|
+
const doboBeforeCreateRecord = {
|
|
2
2
|
level: 1000,
|
|
3
|
-
handler: async function (
|
|
3
|
+
handler: async function (modelName, body, options = {}) {
|
|
4
4
|
const { get } = this.app.lib._
|
|
5
|
-
const { getField } = this.app.dobo
|
|
6
5
|
const { req } = options
|
|
7
6
|
|
|
8
7
|
if (options.noAutoFilter || !req) return
|
|
9
8
|
const item = { siteId: 'site.id', userId: 'user.id' }
|
|
9
|
+
const model = this.app.dobo.getModel(modelName)
|
|
10
10
|
for (const i in item) {
|
|
11
11
|
const rec = get(req, item[i])
|
|
12
|
-
const field =
|
|
12
|
+
const field = model.getProperty(i)
|
|
13
13
|
if (rec && field) body[i] = field.type === 'string' ? (rec + '') : rec
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export default
|
|
18
|
+
export default doboBeforeCreateRecord
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const useAdmin = ['waibuAdmin']
|
|
2
2
|
|
|
3
|
-
export async function rebuildFilter (
|
|
3
|
+
export async function rebuildFilter (modelName, filter, req) {
|
|
4
4
|
const { isEmpty, map, find, get } = this.app.lib._
|
|
5
|
-
const { hasField } = this.app.dobo
|
|
6
5
|
filter.query = filter.query ?? {}
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
6
|
+
const model = this.app.dobo.getModel(modelName)
|
|
7
|
+
const hasSiteId = model.hasProperty('siteId')
|
|
8
|
+
const hasUserId = model.hasProperty('userId')
|
|
9
|
+
const hasTeamId = model.hasProperty('teamId')
|
|
10
10
|
const isAdmin = find(get(req, 'user.teams', []), { alias: 'administrator' }) && useAdmin.includes(get(req, 'routeOptions.config.ns'))
|
|
11
11
|
if (!(hasSiteId || hasUserId || hasTeamId)) return filter
|
|
12
12
|
const q = { $and: [] }
|
|
@@ -26,15 +26,15 @@ export async function rebuildFilter (model, filter, req) {
|
|
|
26
26
|
return filter
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export async function handler (
|
|
29
|
+
export async function handler (modelName, filter, options = {}) {
|
|
30
30
|
const { req } = options
|
|
31
31
|
if (options.noAutoFilter || !req) return
|
|
32
|
-
filter = await rebuildFilter.call(this,
|
|
32
|
+
filter = await rebuildFilter.call(this, modelName, filter, req)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const doboBeforeFindRecord = {
|
|
36
36
|
level: 1000,
|
|
37
37
|
handler
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export default
|
|
40
|
+
export default doboBeforeFindRecord
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { rebuildFilter } from './dobo@before-find-record.js'
|
|
2
|
+
|
|
3
|
+
export async function checker (modelName, id, options = {}) {
|
|
4
|
+
const { req } = options
|
|
5
|
+
|
|
6
|
+
const model = this.app.dobo.getModel(modelName)
|
|
7
|
+
if (options.noAutoFilter || !req) return
|
|
8
|
+
const filter = await rebuildFilter.call(this, modelName, {}, req)
|
|
9
|
+
if (filter.query.$and) filter.query.$and.push({ id })
|
|
10
|
+
else filter.query.id = id
|
|
11
|
+
filter.limit = 1
|
|
12
|
+
const rows = await model.findRecord(filter, { count: false })
|
|
13
|
+
if (rows.length === 0) throw this.app.dobo.error('recordNotFound%s%s', id, this.name, { statusCode: 404 })
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const doboBeforeGetRecord = {
|
|
17
|
+
level: 1000,
|
|
18
|
+
handler: async function (modelName, id, options) {
|
|
19
|
+
await checker.call(this, modelName, id, options)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default doboBeforeGetRecord
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { checker } from './dobo@before-get-record.js'
|
|
2
|
+
|
|
3
|
+
const doboBeforeRemoveRecord = {
|
|
4
|
+
level: 1000,
|
|
5
|
+
handler: async function (modelName, id, options = {}) {
|
|
6
|
+
await checker.call(this, modelName, id, options.req)
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default doboBeforeRemoveRecord
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { checker } from './dobo@before-get-record.js'
|
|
2
|
+
|
|
3
|
+
const doboBeforeUpdateRecord = {
|
|
4
|
+
level: 1000,
|
|
5
|
+
handler: async function (modelName, id, body, options = {}) {
|
|
6
|
+
await checker.call(this, modelName, id, options)
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default doboBeforeUpdateRecord
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/extend/bajo/intl/id.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|