sumba 1.0.16 → 1.0.17

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.
@@ -2,7 +2,7 @@ import checkUserId from '../../lib/check-user-id.js'
2
2
  import checkTheme from '../../lib/check-theme.js'
3
3
  import checkIconset from '../../lib/check-iconset.js'
4
4
 
5
- const onRequest = {
5
+ const preParsing = {
6
6
  level: 10,
7
7
  handler: async function (req, reply) {
8
8
  const { routePath } = this.app.waibu
@@ -29,4 +29,4 @@ const onRequest = {
29
29
  }
30
30
  }
31
31
 
32
- export default onRequest
32
+ export default preParsing
@@ -40,6 +40,15 @@ async function anonymous (req) {
40
40
  }
41
41
  }
42
42
 
43
+ async function misc (req) {
44
+ const { omit } = this.app.bajo.lib._
45
+ const { getUser } = this
46
+ if (!req.session) return
47
+ if (req.session.user) {
48
+ req.user = omit(await getUser(req.session.user.id), ['password', 'token'])
49
+ }
50
+ }
51
+
43
52
  async function mergeSetting (req) {
44
53
  req.user.setting = {}
45
54
  }
@@ -48,7 +57,10 @@ async function checkUserId (req, reply, source) {
48
57
  const { isEmpty, camelCase } = this.app.bajo.lib._
49
58
 
50
59
  const ctx = this.app[source].instance
51
- if (!req.routeOptions.url) return
60
+ if (!req.routeOptions.url) {
61
+ await misc.call(this, req)
62
+ return
63
+ }
52
64
  const match = await checker.call(this, req, this.secureRoutes)
53
65
  if (!match) {
54
66
  await anonymous.call(this, req)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Bajo Framework's Biz Suite",
5
5
  "main": "index.js",
6
6
  "scripts": {