sumba 1.2.1 → 1.2.3

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.
@@ -6,7 +6,7 @@ async function afterRecordCreate (body, options = {}, rec) {
6
6
  const to = `${data.firstName} ${data.lastName} <${data.email}>`
7
7
  const subject = options.req.t('newUserSignup')
8
8
  await sendMail(
9
- 'sumba.template:/_mail/user-signup-success.html',
9
+ `sumba.template:/_mail/user-signup-success${data.status === 'ACTIVE' ? '-active' : ''}.html`,
10
10
  { to, subject, data, options, source: this.name }
11
11
  )
12
12
  }
@@ -0,0 +1,8 @@
1
+ <p>Congratulations, your account has been created successfully. Thus you can now access the Members-only pages
2
+ according to the permissions set by your Admin.</p>
3
+
4
+ <p>If you still have questions, please don't hesitate to
5
+ fill out the form on the <strong>Help</strong> page.
6
+ We will be happy to answer all your questions.</p>
7
+
8
+ <p>Thank you for joining us. We hope our services will benefit you</p>
@@ -0,0 +1,10 @@
1
+ <p>Selamat, akun Anda telah berhasil dibuat. Dengan demikian Anda telah bisa mengakses
2
+ halaman-halaman khusus Anggota sesuai dengan permisi yang ditetapkan oleh
3
+ Admin Anda.</p>
4
+
5
+ <p>Jika Anda masih memiliki pertanyaan-pertanyaan, silahkan untuk tidak segan
6
+ mengisi formulir di halaman <strong>Bantuan</strong>. Dengan senang hati
7
+ kami akan menjawab semua pertanyaan Anda.</p>
8
+
9
+ <p>Terima kasih telah bergabung bersama kami, semoga layanan kami
10
+ membawa manfaat untuk Anda.</p>
@@ -13,5 +13,5 @@ ada di halaman tersebut dan tekan tombol <strong>Kirim</strong>:</p>
13
13
 
14
14
  <strong><%= token %></strong>
15
15
 
16
- <p>Sekali lagi terimakasih telah bergabung bersama kami, semoga layanan kami
16
+ <p>Sekali lagi terima kasih telah bergabung bersama kami, semoga layanan kami
17
17
  membawa manfaat untuk Anda.<p>
@@ -1,4 +1,4 @@
1
- <c:footer margin="top-5">
1
+ <c:footer margin="top-4">
2
2
  <c:div id="footer"></c:div>
3
3
  <small>
4
4
  <c:nav flex="justify-content:center" tag="ul">
@@ -0,0 +1,8 @@
1
+ <% if (_hasPlugin('sumbaOauth')) { %>
2
+ <c:div margin="bottom-2" flex="justify-content:center" t:content="<%= attr.label %>" />
3
+ <c:div flex="justify-content:center" margin="bottom-3">
4
+ <% for (const p of oauthProviders) { %>
5
+ <c:btn color="primary-outline" content="<%= _.upperFirst(p) %>" icon="logo<%= _.upperFirst(p) %>" href="sumbaOauth:/<%= p %>" margin="x-1"/>
6
+ <% } %>
7
+ </c:div>
8
+ <% } %>
@@ -3,9 +3,12 @@
3
3
  <c:form-password name="password" label-floating wrapper-margin="bottom-3" />
4
4
  </c:form>
5
5
  <c:div move-to="#footer" flex="justify-content:center">
6
- <c:nav type="inline">
7
- <!-- include sumba.partial:/list-item/forgot-password.html -->
8
- <!-- include sumba.partial:/list-item/user-signup.html -->
9
- <!-- include sumba.partial:/list-item/goto-home.html -->
10
- </c:nav>
6
+ <c:div>
7
+ <!-- include sumba.partial:/list-item/oauth-signin.html|<%= JSON.stringify({ label: 'orSigninThrough' }) %> -->
8
+ <c:nav type="inline">
9
+ <!-- include sumba.partial:/list-item/forgot-password.html -->
10
+ <!-- include sumba.partial:/list-item/user-signup.html -->
11
+ <!-- include sumba.partial:/list-item/goto-home.html -->
12
+ </c:nav>
13
+ </c:div>
11
14
  </c:div>
@@ -9,10 +9,13 @@
9
9
  </c:form>
10
10
  <% if (!page.noLinks) { %>
11
11
  <c:div move-to="#footer" flex="justify-content:center">
12
- <c:nav type="inline">
13
- <!-- include sumba.partial:/list-item/forgot-password.html -->
14
- <!-- include sumba.partial:/list-item/signin.html -->
15
- <!-- include sumba.partial:/list-item/goto-home.html -->
16
- </c:nav>
12
+ <c:div>
13
+ <!-- include sumba.partial:/list-item/oauth-signin.html|<%= JSON.stringify({ label: 'orSignupThrough' }) %> -->
14
+ <c:nav type="inline">
15
+ <!-- include sumba.partial:/list-item/forgot-password.html -->
16
+ <!-- include sumba.partial:/list-item/signin.html -->
17
+ <!-- include sumba.partial:/list-item/goto-home.html -->
18
+ </c:nav>
19
+ </c:div>
17
20
  </c:div>
18
21
  <% } %>
@@ -0,0 +1,3 @@
1
+ ---
2
+ layout: waibu.layout:/email.html
3
+ ---
@@ -10,6 +10,7 @@
10
10
  "zipCode": "12345",
11
11
  "provinceState": "State",
12
12
  "country": "US",
13
+ "provider": "local",
13
14
  "siteId": "?:SumbaSite::alias:default",
14
15
  "status": "ACTIVE"
15
16
  }]
@@ -21,12 +21,18 @@
21
21
  "type": "string",
22
22
  "maxLength": 50,
23
23
  "required": true
24
+ }, {
25
+ "name": "provider",
26
+ "type": "string",
27
+ "maxLength": 50,
28
+ "index": true,
29
+ "required": true,
30
+ "default": "local"
24
31
  }, {
25
32
  "name": "email",
26
33
  "type": "string",
27
34
  "maxLength": 100,
28
35
  "required": true,
29
- "index": true,
30
36
  "rules": ["email"]
31
37
  }, {
32
38
  "name": "firstName",
package/index.js CHANGED
@@ -198,7 +198,7 @@ async function factory (pkgName) {
198
198
  await validate({ username, password }, model, { ns: ['sumba', 'dobo'], fields: ['username', 'password'] })
199
199
  const bcrypt = await importPkg('bajoExtra:bcrypt')
200
200
 
201
- const query = { username }
201
+ const query = { username, provider: 'local' }
202
202
  const rows = await recordFind(model, { query }, { req, forceNoHidden: true, noHook: true })
203
203
  if (rows.length === 0) throw this.error('validationError', { details: [{ field: 'username', error: 'Unknown username' }], statusCode: 401 })
204
204
  const rec = rows[0]
@@ -433,6 +433,34 @@ async function factory (pkgName) {
433
433
  await mergeSetting(site)
434
434
  return site
435
435
  }
436
+
437
+ signin = async ({ user, req, reply }) => {
438
+ const { getSessionId } = this.app.waibuMpa
439
+ const { runHook } = this.app.bajo
440
+ const { isEmpty, omit } = this.lib._
441
+ let { referer } = req.body || {}
442
+ if (req.session.ref) referer = req.session.ref
443
+ req.session.ref = null
444
+ const _user = omit(user, ['password', 'token'])
445
+ req.session.userId = _user.id
446
+ const sid = await getSessionId(req.headers.cookie)
447
+ await runHook(`${this.name}:afterSignin`, _user, sid, req)
448
+ const { query, params } = req
449
+ const url = !isEmpty(referer) ? referer : this.config.redirect.afterSignin
450
+ req.flash('notify', req.t('signinSuccessfully'))
451
+ return reply.redirectTo(url, { query, params })
452
+ }
453
+
454
+ generatePassword = (req) => {
455
+ const { generateId } = this.app.bajo
456
+ const cfg = req ? req.site.setting.sumba.userPassword : this.config.siteSetting.userPassword
457
+ let passwd = generateId()
458
+ if (cfg.minLowercase) passwd += generateId({ pattern: 'abcdefghijklmnopqrstuvwxyz', length: cfg.minLowercase })
459
+ if (cfg.minUppercase) passwd += generateId({ pattern: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', length: cfg.minUppercase })
460
+ if (cfg.minSpecialChar) passwd += generateId({ pattern: '!@#$%*', length: cfg.minSpecialChar })
461
+ if (cfg.minNumeric) passwd += generateId({ pattern: '0123456789', length: cfg.minNumeric })
462
+ return passwd
463
+ }
436
464
  }
437
465
  }
438
466
 
@@ -9,7 +9,7 @@ async function passwordRule (req) {
9
9
  .min(8)
10
10
  .max(100)
11
11
  .required()
12
- const cfg = req ? req.site.setting.sumba.userPassword : this.config.siteSetting
12
+ const cfg = req ? req.site.setting.sumba.userPassword : this.config.siteSetting.userPassword
13
13
  if (cfg.minUppercase) password = password.minOfUppercase(cfg.minUppercase)
14
14
  if (cfg.minLowercase) password = password.minOfLowercase(cfg.minLowercase)
15
15
  if (cfg.minSpecialChar) password = password.minOfSpecialCharacters(cfg.minSpecialChar)
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Bajo Framework's Biz Suite",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },
9
9
  "type": "module",
10
+ "bajo": {
11
+ "type": "plugin"
12
+ },
10
13
  "repository": {
11
14
  "type": "git",
12
15
  "url": "git+https://github.com/ardhi/sumba.git"
@@ -1,26 +1,14 @@
1
1
  const signin = {
2
2
  method: ['GET', 'POST'],
3
3
  handler: async function (req, reply) {
4
- const { getUserFromUsernamePassword } = this
5
- const { runHook } = this.app.bajo
6
- const { isEmpty, omit } = this.lib._
7
- const { getSessionId } = this.app.waibuMpa
8
-
9
4
  let { username, password, referer } = req.body || {}
10
5
  if (req.session.ref) referer = req.session.ref
11
6
  req.session.ref = null
12
7
  let error
13
8
  if (req.method === 'POST') {
14
9
  try {
15
- const user = omit(await getUserFromUsernamePassword(username, password, req), ['password', 'token'])
16
- req.session.userId = user.id
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)
20
- const { query, params } = req
21
- const url = !isEmpty(referer) ? referer : this.config.redirect.afterSignin
22
- req.flash('notify', req.t('signinSuccessfully'))
23
- return reply.redirectTo(url, { query, params })
10
+ const user = await this.getUserFromUsernamePassword(username, password, req)
11
+ return await this.signin({ user, req, reply })
24
12
  } catch (err) {
25
13
  error = err
26
14
  }
@@ -23,6 +23,7 @@ const signup = {
23
23
  const fields = ['username', 'password', 'verifyPassword', 'email', 'firstName', 'lastName', 'agree']
24
24
  const validation = { ns: ['sumba', 'dobo'], fields, extFields }
25
25
  req.body.token = generateId()
26
+ req.body.provider = 'local'
26
27
  const { data } = await recordCreate({ model: 'SumbaUser', req, reply, options: { validation, noFlash: true, forceNoHidden: true } })
27
28
  req.flash('notify', req.t('userCreated'))
28
29
  return reply.view('sumba.template:/user/signup/success.html', { form: req.body, data })