sumba 1.0.13 → 1.0.15

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/bajo/config.json CHANGED
@@ -52,8 +52,9 @@
52
52
  },
53
53
  "redirect": {
54
54
  "signin": "sumba:/signin",
55
+ "afterSignin": "/",
55
56
  "signout": "sumba:/signout",
56
- "home": "sumba:/"
57
+ "afterSignout": "/"
57
58
  },
58
59
  "userPassword": {
59
60
  "minUppercase": 1,
@@ -4,6 +4,11 @@
4
4
  "email": "admin@domain.com",
5
5
  "firstName": "Site",
6
6
  "lastName": "Admin",
7
+ "address1": "Address Line 1",
8
+ "address2": "Address Line 2",
9
+ "city": "City Name",
10
+ "zipCode": "12345",
11
+ "provinceState": "State",
7
12
  "country": "US",
8
13
  "siteId": "?:SumbaSite::alias:default",
9
14
  "status": "ACTIVE"
@@ -1,21 +1,27 @@
1
1
  async function mergeSetting (req) {
2
- const { trim } = this.app.bajo.lib._
2
+ const { defaultsDeep } = this.app.bajo
3
+ const { trim, get, filter } = this.app.bajo.lib._
3
4
  const { recordFind } = this.app.dobo
4
- const setting = {}
5
+ const defSetting = {}
6
+ const nsSetting = {}
5
7
  const query = {
6
8
  ns: { $in: this.app.bajo.pluginNames },
7
9
  siteId: req.site.id
8
10
  }
9
- const items = await recordFind('SumbaSiteSetting', { query, limit: 200 })
10
- for (const item of items) {
11
- setting[item.ns] = setting[item.ns] ?? {}
12
- let value = trim([item.value] ?? '')
13
- if (['[', '{'].includes(value[0])) value = JSON.parse(value)
14
- else if (Number(value)) value = Number(value)
15
- else if (['true', 'false'].includes(value)) value = value === 'true'
16
- setting[item.ns][item.key] = value
11
+ const all = await recordFind('SumbaSiteSetting', { query, limit: -1 })
12
+ for (const ns of this.app.bajo.pluginNames) {
13
+ nsSetting[ns] = {}
14
+ defSetting[ns] = get(this, `app.${ns}.config.siteSetting`, {})
15
+ const items = filter(all, { ns })
16
+ for (const item of items) {
17
+ let value = trim([item.value] ?? '')
18
+ if (['[', '{'].includes(value[0])) value = JSON.parse(value)
19
+ else if (Number(value)) value = Number(value)
20
+ else if (['true', 'false'].includes(value)) value = value === 'true'
21
+ nsSetting[ns][item.key] = value
22
+ }
17
23
  }
18
- req.site.setting = setting
24
+ req.site.setting = defaultsDeep({}, nsSetting, defSetting)
19
25
  }
20
26
 
21
27
  const omitted = ['status']
@@ -24,7 +24,7 @@ async function checker (req, container) {
24
24
  }
25
25
 
26
26
  async function anonymous (req) {
27
- const { pick } = this.app.bajo.lib._
27
+ const { omit } = this.app.bajo.lib._
28
28
  const { getUser } = this
29
29
  const { routePath } = this.app.waibu
30
30
 
@@ -36,7 +36,7 @@ async function anonymous (req) {
36
36
  req.session.ref = req.url
37
37
  throw this.error('redirect', { redirect: redir })
38
38
  }
39
- req.user = pick(await getUser(req.session.user.id), ['id', 'username', 'email', 'firstName', 'lastName'])
39
+ req.user = omit(await getUser(req.session.user.id), ['password', 'token'])
40
40
  }
41
41
  }
42
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Bajo Framework's Biz Suite",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,7 +1,9 @@
1
1
  <% if (_meta.user) { %>
2
2
  <c:list-item href="sumba:/my-stuff/profile" t:content="Your Profile" />
3
3
  <c:list-item href="sumba:/my-stuff/change-password" t:content="Change Password" />
4
- <c:list-item href="sumba:/signout" t:content="Signout" />
4
+ <% if (attr.withSignout) { %>
5
+ <c:list-item href="sumba:/signout" t:content="Signout" />
6
+ <% } %>
5
7
  <% } else { %>
6
8
  <c:list-item href="sumba:/signin" t:content="Signin" />
7
9
  <c:list-item href="sumba:/user/signup" t:content="New User Signup" />
@@ -0,0 +1,11 @@
1
+ <c:form button reset-validation referer>
2
+ <c:form-input name="username" label-floating wrapper-margin="bottom-2" />
3
+ <c:form-password name="password" label-floating wrapper-margin="bottom-3" />
4
+ </c:form>
5
+ <% if (!page.noLinks) { %>
6
+ <c:list type="unstyled" margin="start-3">
7
+ <c:include resource="sumba.partial:/list-item/forgot-password.html" />
8
+ <c:include resource="sumba.partial:/list-item/user-signup.html" />
9
+ <c:include resource="sumba.partial:/list-item/goto-home.html" />
10
+ </c:list>
11
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <c:p t:content="signoutWarning" />
2
+ <c:form method="POST" action="sumba:/signout" referer>
3
+ <c:btn color="primary" t:content="Yes, sign me out now!" type="submit" />
4
+ <% if (!page.noLinks) { %>
5
+ <c:btn color="link" icon="house" t:content="Goto Home" href="/" />
6
+ <% } %>
7
+ </c:form>
@@ -3,7 +3,7 @@ const signin = {
3
3
  handler: async function (req, reply) {
4
4
  const { getUserFromUsernamePassword } = this
5
5
  const { runHook } = this.app.bajo
6
- const { isEmpty, pick } = this.app.bajo.lib._
6
+ const { isEmpty, omit } = this.app.bajo.lib._
7
7
  const { getSessionId } = this.app.waibuMpa
8
8
 
9
9
  let { username, password, referer } = req.body || {}
@@ -12,13 +12,13 @@ const signin = {
12
12
  let error
13
13
  if (req.method === 'POST') {
14
14
  try {
15
- const user = pick(await getUserFromUsernamePassword(username, password, req), ['id', 'username', 'email', 'siteId'])
15
+ const user = omit(await getUserFromUsernamePassword(username, password, req), ['password', 'token'])
16
16
  req.session.user = user
17
17
  const sid = await getSessionId(req.headers.cookie)
18
18
  if (this.bajoEmitter) await this.app.bajoEmitter.emit(`${this.name}.signin`, user, sid)
19
19
  await runHook(`${this.name}:afterSignin`, user, sid, req)
20
20
  const { query, params } = req
21
- const url = !isEmpty(referer) ? referer : this.config.redirect.home
21
+ const url = !isEmpty(referer) ? referer : this.config.redirect.afterSignin
22
22
  req.flash('notify', req.t('You\'ve successfully signed in!'))
23
23
  return reply.redirectTo(url, { query, params })
24
24
  } catch (err) {
@@ -2,7 +2,7 @@ const signout = {
2
2
  method: ['GET', 'POST'],
3
3
  handler: async function (req, reply) {
4
4
  const { runHook } = this.app.bajo
5
- const { isEmpty } = this.app.bajo.lib._
5
+ // const { isEmpty } = this.app.bajo.lib._
6
6
  const { getSessionId } = this.app.waibuMpa
7
7
 
8
8
  let { referer } = req.body || {}
@@ -15,7 +15,8 @@ const signout = {
15
15
  if (this.bajoEmitter) await this.app.bajoEmitter.emit(`${this.name}.sigout`, user, sid)
16
16
  await runHook(`${this.name}:afterSignout`, user, sid, req)
17
17
  const { query, params } = req
18
- const url = !isEmpty(referer) ? referer : this.config.redirect.home
18
+ // const url = !isEmpty(referer) ? referer : this.config.redirect.home
19
+ const url = this.config.redirect.afterSignout
19
20
  req.flash('notify', req.t('You\'ve successfully signed out!'))
20
21
  return reply.redirectTo(url, { query, params })
21
22
  }
@@ -1,14 +1,3 @@
1
1
  ---
2
2
  t:title: Signin
3
3
  ---
4
- <c:form button reset-validation referer>
5
- <c:form-input name="username" label-floating wrapper-margin="bottom-2" />
6
- <c:form-password name="password" label-floating wrapper-margin="bottom-3" />
7
- </c:form>
8
- <% if (!page.noLinks) { %>
9
- <c:list type="unstyled" margin="start-3">
10
- <c:include resource="sumba.partial:/list-item/forgot-password.html" />
11
- <c:include resource="sumba.partial:/list-item/user-signup.html" />
12
- <c:include resource="sumba.partial:/list-item/goto-home.html" />
13
- </c:list>
14
- <% } %>
@@ -1,10 +1,3 @@
1
1
  ---
2
2
  t:title: Signout
3
3
  ---
4
- <c:p t:content="signoutWarning" />
5
- <c:form method="POST" action="sumba:/signout" referer>
6
- <c:btn color="primary" t:content="Yes, sign me out now!" type="submit" />
7
- <% if (!page.noLinks) { %>
8
- <c:btn color="link" icon="house" t:content="Goto Home" href="/" />
9
- <% } %>
10
- </c:form>