sumba 1.0.12 → 1.0.13

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.
@@ -0,0 +1,8 @@
1
+ import { handler } from './dobo@before-record-find.js'
2
+
3
+ const doboBeforeRecordCount = {
4
+ level: 1000,
5
+ handler
6
+ }
7
+
8
+ export default doboBeforeRecordCount
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Bajo Framework's Biz Suite",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,7 +2,9 @@ const signin = {
2
2
  method: ['GET', 'POST'],
3
3
  handler: async function (req, reply) {
4
4
  const { getUserFromUsernamePassword } = this
5
+ const { runHook } = this.app.bajo
5
6
  const { isEmpty, pick } = this.app.bajo.lib._
7
+ const { getSessionId } = this.app.waibuMpa
6
8
 
7
9
  let { username, password, referer } = req.body || {}
8
10
  if (req.session.ref) referer = req.session.ref
@@ -11,8 +13,10 @@ const signin = {
11
13
  if (req.method === 'POST') {
12
14
  try {
13
15
  const user = pick(await getUserFromUsernamePassword(username, password, req), ['id', 'username', 'email', 'siteId'])
14
- if (this.bajoEmitter) await this.app.bajoEmitter.emit('sumba.signin', user)
15
16
  req.session.user = user
17
+ const sid = await getSessionId(req.headers.cookie)
18
+ if (this.bajoEmitter) await this.app.bajoEmitter.emit(`${this.name}.signin`, user, sid)
19
+ await runHook(`${this.name}:afterSignin`, user, sid, req)
16
20
  const { query, params } = req
17
21
  const url = !isEmpty(referer) ? referer : this.config.redirect.home
18
22
  req.flash('notify', req.t('You\'ve successfully signed in!'))
@@ -1,13 +1,19 @@
1
1
  const signout = {
2
2
  method: ['GET', 'POST'],
3
3
  handler: async function (req, reply) {
4
+ const { runHook } = this.app.bajo
4
5
  const { isEmpty } = this.app.bajo.lib._
6
+ const { getSessionId } = this.app.waibuMpa
5
7
 
6
8
  let { referer } = req.body || {}
7
9
  if (req.session.ref) referer = req.session.ref
8
10
  req.session.ref = null
9
11
  if (req.method === 'POST') {
12
+ const sid = await getSessionId(req.headers.cookie)
13
+ const user = req.session.user
10
14
  req.session.user = null
15
+ if (this.bajoEmitter) await this.app.bajoEmitter.emit(`${this.name}.sigout`, user, sid)
16
+ await runHook(`${this.name}:afterSignout`, user, sid, req)
11
17
  const { query, params } = req
12
18
  const url = !isEmpty(referer) ? referer : this.config.redirect.home
13
19
  req.flash('notify', req.t('You\'ve successfully signed out!'))