sumba 2.25.0 → 2.26.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/extend/bajo/hook.js +430 -0
- package/extend/dobo/fixture/team-user.json +2 -2
- package/extend/dobo/model.js +215 -0
- package/extend/dobo/model.json +214 -0
- package/index.js +11 -7
- package/lib/get-user.js +1 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +9 -0
- package/extend/bajo/hook/bajo.extend@after-read-config.js +0 -13
- package/extend/bajo/hook/dobo.sumba-attrib-guard$dobo.sumba-x-attrib-guard@after-transaction.js +0 -6
- package/extend/bajo/hook/dobo.sumba-contact-form@after-create-record.js +0 -17
- package/extend/bajo/hook/dobo.sumba-contact-form@before-create-record.js +0 -16
- package/extend/bajo/hook/dobo.sumba-model-guard$dobo.sumba-x-model-guard@after-transaction.js +0 -6
- package/extend/bajo/hook/dobo.sumba-route-guard$dobo.sumba-x-route-guard@after-transaction.js +0 -6
- package/extend/bajo/hook/dobo.sumba-site@after-create-record.js +0 -8
- package/extend/bajo/hook/dobo.sumba-site@after-remove-record.js +0 -9
- package/extend/bajo/hook/dobo.sumba-site@after-update-record.js +0 -14
- package/extend/bajo/hook/dobo.sumba-team$dobo.sumba-site@after-transaction.js +0 -8
- package/extend/bajo/hook/dobo.sumba-user@after-create-record.js +0 -15
- package/extend/bajo/hook/dobo.sumba-user@after-record-validation.js +0 -8
- package/extend/bajo/hook/dobo.sumba-user@after-remove-record.js +0 -7
- package/extend/bajo/hook/dobo.sumba-user@after-update-record.js +0 -44
- package/extend/bajo/hook/dobo.sumba-user@before-create-record.js +0 -7
- package/extend/bajo/hook/dobo.sumba-user@before-record-validation.js +0 -8
- package/extend/bajo/hook/dobo.sumba-user@before-update-record.js +0 -9
- package/extend/bajo/hook/dobo@before-count-record.js +0 -8
- package/extend/bajo/hook/dobo@before-driver-create-record.js +0 -17
- package/extend/bajo/hook/dobo@before-driver-find-all-record.js +0 -13
- package/extend/bajo/hook/dobo@before-driver-find-record.js +0 -114
- package/extend/bajo/hook/dobo@before-driver-get-record.js +0 -22
- package/extend/bajo/hook/dobo@before-driver-remove-record.js +0 -10
- package/extend/bajo/hook/dobo@before-driver-update-record.js +0 -10
- package/extend/bajo/hook/waibu-mpa.sumba@after-build-locals.js +0 -19
- package/extend/bajo/hook/waibu-mpa@pre-parsing.js +0 -15
- package/extend/bajo/hook/waibu-rest-api@pre-parsing.js +0 -13
- package/extend/bajo/hook/waibu-static@pre-parsing.js +0 -13
- package/extend/bajo/hook/waibu@after-app-boot.js +0 -7
- package/extend/bajo/hook/waibu@after-create-context.js +0 -5
- package/extend/bajo/hook/waibu@pre-parsing.js +0 -9
- package/extend/dobo/model/attrib-guard.js +0 -32
- package/extend/dobo/model/contact-form-cat.json +0 -3
- package/extend/dobo/model/contact-form.json +0 -16
- package/extend/dobo/model/download.json +0 -19
- package/extend/dobo/model/model-guard.js +0 -48
- package/extend/dobo/model/route-guard.js +0 -48
- package/extend/dobo/model/site-setting.json +0 -16
- package/extend/dobo/model/site.json +0 -45
- package/extend/dobo/model/team-setting.json +0 -17
- package/extend/dobo/model/team-user.json +0 -16
- package/extend/dobo/model/team.json +0 -23
- package/extend/dobo/model/ticket-cat.json +0 -3
- package/extend/dobo/model/ticket-detail.json +0 -7
- package/extend/dobo/model/ticket.json +0 -31
- package/extend/dobo/model/user-setting.json +0 -17
- package/extend/dobo/model/user.js +0 -84
- package/extend/dobo/model/x-attrib-guard.js +0 -14
- package/extend/dobo/model/x-model-guard.js +0 -13
- package/extend/dobo/model/x-route-guard.js +0 -13
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
[{
|
|
2
|
+
"baseName": "contact-form-cat",
|
|
3
|
+
"features": ["sumba:category", "sumba:siteId"]
|
|
4
|
+
}, {
|
|
5
|
+
"baseName": "contact-form",
|
|
6
|
+
"properties": [
|
|
7
|
+
"firstName,,50,true,true",
|
|
8
|
+
"lastName,,50,true,true",
|
|
9
|
+
"email,,50,true,true",
|
|
10
|
+
"category,,50,true",
|
|
11
|
+
"subject,,255,,true",
|
|
12
|
+
"message,text"
|
|
13
|
+
],
|
|
14
|
+
"features": [{
|
|
15
|
+
"name": "sumba:status",
|
|
16
|
+
"default": "NEW",
|
|
17
|
+
"values": ["NEW", "ACK"]
|
|
18
|
+
}, "sumba:userId", "sumba:siteId", "dobo:createdAt", "dobo:updatedAt"
|
|
19
|
+
]
|
|
20
|
+
}, {
|
|
21
|
+
"baseName": "download",
|
|
22
|
+
"properties": [
|
|
23
|
+
"description,,50,true",
|
|
24
|
+
"file,text,,,true",
|
|
25
|
+
"type,,20,true",
|
|
26
|
+
"jobQueue,object",
|
|
27
|
+
{
|
|
28
|
+
"name": "size",
|
|
29
|
+
"type": "integer",
|
|
30
|
+
"default": 0,
|
|
31
|
+
"index": true
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"features": ["sumba:siteId", "sumba:userId", "dobo:createdAt", "dobo:updatedAt", {
|
|
35
|
+
"name": "sumba:status",
|
|
36
|
+
"default": "INQUEUE",
|
|
37
|
+
"values": ["INQUEUE", "PROCESSING", "COMPLETE", "FAIL"]
|
|
38
|
+
}]
|
|
39
|
+
}, {
|
|
40
|
+
"baseName": "site-setting",
|
|
41
|
+
"properties": [
|
|
42
|
+
"ns,,50,true,true",
|
|
43
|
+
"key,,255,true,true",
|
|
44
|
+
"value,text"
|
|
45
|
+
],
|
|
46
|
+
"indexes": [{
|
|
47
|
+
"fields": ["ns", "key", "siteId"],
|
|
48
|
+
"type": "unique"
|
|
49
|
+
}],
|
|
50
|
+
"features": [
|
|
51
|
+
"sumba:siteId",
|
|
52
|
+
"dobo:immutable",
|
|
53
|
+
"dobo:updatedAt"
|
|
54
|
+
]
|
|
55
|
+
}, {
|
|
56
|
+
"buildLevel": 1,
|
|
57
|
+
"baseName": "site",
|
|
58
|
+
"properties": [{
|
|
59
|
+
"name": "hostname",
|
|
60
|
+
"type": "string",
|
|
61
|
+
"maxLength": 100,
|
|
62
|
+
"required": true,
|
|
63
|
+
"index": "unique"
|
|
64
|
+
}, {
|
|
65
|
+
"name": "alias",
|
|
66
|
+
"type": "string",
|
|
67
|
+
"maxLength": 100,
|
|
68
|
+
"index": "unique",
|
|
69
|
+
"required": true,
|
|
70
|
+
"immutable": true
|
|
71
|
+
}, {
|
|
72
|
+
"name": "title",
|
|
73
|
+
"type": "string",
|
|
74
|
+
"maxLength": 50,
|
|
75
|
+
"required": true
|
|
76
|
+
}, {
|
|
77
|
+
"name": "orgName",
|
|
78
|
+
"type": "string",
|
|
79
|
+
"maxLength": 100,
|
|
80
|
+
"index": true
|
|
81
|
+
}, {
|
|
82
|
+
"name": "email",
|
|
83
|
+
"type": "string",
|
|
84
|
+
"maxLength": 100,
|
|
85
|
+
"rules": ["email"]
|
|
86
|
+
}],
|
|
87
|
+
"features": [
|
|
88
|
+
"sumba:personInCharge",
|
|
89
|
+
"sumba:address",
|
|
90
|
+
"sumba:social",
|
|
91
|
+
{
|
|
92
|
+
"name": "sumba:status",
|
|
93
|
+
"default": "ACTIVE"
|
|
94
|
+
},
|
|
95
|
+
"dobo:createdAt",
|
|
96
|
+
"dobo:updatedAt",
|
|
97
|
+
"dobo:immutable"
|
|
98
|
+
],
|
|
99
|
+
"scanables": ["hostname", "alias", "title", "orgName"]
|
|
100
|
+
}, {
|
|
101
|
+
"buildLevel": 5,
|
|
102
|
+
"baseName": "team-setting",
|
|
103
|
+
"properties": [
|
|
104
|
+
"ns,,50,true,true",
|
|
105
|
+
"key,,255,true,true",
|
|
106
|
+
"value,text"
|
|
107
|
+
],
|
|
108
|
+
"indexes": [{
|
|
109
|
+
"fields": ["ns", "key", "siteId", "teamId"],
|
|
110
|
+
"type": "unique"
|
|
111
|
+
}],
|
|
112
|
+
"features": [
|
|
113
|
+
"sumba:siteId",
|
|
114
|
+
"dobo:updatedAt",
|
|
115
|
+
"sumba:teamId"
|
|
116
|
+
]
|
|
117
|
+
}, {
|
|
118
|
+
"buildLevel": 4,
|
|
119
|
+
"baseName": "team-user",
|
|
120
|
+
"properties": [],
|
|
121
|
+
"indexes": [{
|
|
122
|
+
"fields": ["userId", "siteId", "teamId"],
|
|
123
|
+
"type": "unique"
|
|
124
|
+
}],
|
|
125
|
+
"features": [
|
|
126
|
+
"dobo:createdAt",
|
|
127
|
+
"dobo:updatedAt",
|
|
128
|
+
"sumba:siteId",
|
|
129
|
+
"sumba:userId",
|
|
130
|
+
"sumba:teamId",
|
|
131
|
+
"dobo:immutable"
|
|
132
|
+
]
|
|
133
|
+
}, {
|
|
134
|
+
"buildLevel": 3,
|
|
135
|
+
"baseName": "team",
|
|
136
|
+
"properties": [
|
|
137
|
+
"alias,,20,,true",
|
|
138
|
+
"name,,50,true,true"
|
|
139
|
+
],
|
|
140
|
+
"indexes": [{
|
|
141
|
+
"fields": ["alias", "siteId"],
|
|
142
|
+
"type": "unique"
|
|
143
|
+
}],
|
|
144
|
+
"features": [
|
|
145
|
+
"dobo:createdAt",
|
|
146
|
+
"dobo:updatedAt",
|
|
147
|
+
"dobo:immutable",
|
|
148
|
+
"sumba:siteId",
|
|
149
|
+
{
|
|
150
|
+
"name": "sumba:status",
|
|
151
|
+
"default": "ENABLED",
|
|
152
|
+
"values": ["ENABLED", "DISABLED"]
|
|
153
|
+
},
|
|
154
|
+
"dobo:immutable"
|
|
155
|
+
]
|
|
156
|
+
}, {
|
|
157
|
+
"baseName": "ticket-cat",
|
|
158
|
+
"features": ["sumba:category", "sumba:siteId"]
|
|
159
|
+
}, {
|
|
160
|
+
"baseName": "ticket-detail",
|
|
161
|
+
"properties": [
|
|
162
|
+
"masterId,,255,true,true",
|
|
163
|
+
"message,text"
|
|
164
|
+
],
|
|
165
|
+
"features": ["dobo:createdAt", "sumba:userId", "sumba:siteId"]
|
|
166
|
+
}, {
|
|
167
|
+
"baseName": "ticket",
|
|
168
|
+
"properties": [
|
|
169
|
+
"subject,,255,true,true",
|
|
170
|
+
{
|
|
171
|
+
"name": "cat",
|
|
172
|
+
"type": "string",
|
|
173
|
+
"maxLength": 50,
|
|
174
|
+
"index": true,
|
|
175
|
+
"required": true,
|
|
176
|
+
"ref": {
|
|
177
|
+
"cat": {
|
|
178
|
+
"model": "SumbaTicketCat",
|
|
179
|
+
"searchField": "name",
|
|
180
|
+
"labelField": "name"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"message,text,,,true"
|
|
185
|
+
],
|
|
186
|
+
"features": [
|
|
187
|
+
"dobo:createdAt",
|
|
188
|
+
"dobo:updatedAt",
|
|
189
|
+
"sumba:siteId",
|
|
190
|
+
"sumba:userId",
|
|
191
|
+
{
|
|
192
|
+
"name": "sumba:status",
|
|
193
|
+
"default": "OPEN",
|
|
194
|
+
"values": ["OPEN", "CLOSED"]
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}, {
|
|
198
|
+
"buildLevel": 5,
|
|
199
|
+
"baseName": "user-setting",
|
|
200
|
+
"properties": [
|
|
201
|
+
"ns,,50,true,true",
|
|
202
|
+
"key,,255,true,true",
|
|
203
|
+
"value,text"
|
|
204
|
+
],
|
|
205
|
+
"indexes": [{
|
|
206
|
+
"fields": ["ns", "key", "siteId", "userId"],
|
|
207
|
+
"type": "unique"
|
|
208
|
+
}],
|
|
209
|
+
"features": [
|
|
210
|
+
"sumba:siteId",
|
|
211
|
+
"dobo:updatedAt",
|
|
212
|
+
"sumba:userId"
|
|
213
|
+
]
|
|
214
|
+
}]
|
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ async function factory (pkgName) {
|
|
|
32
32
|
super(pkgName, me.app)
|
|
33
33
|
this.config = {
|
|
34
34
|
multiSite: cloneDeep(defMultiSite),
|
|
35
|
-
|
|
35
|
+
xSiteAdmins: [], // format: "<siteAlias>:<username>"
|
|
36
36
|
waibu: {
|
|
37
37
|
title: 'site',
|
|
38
38
|
prefix: 'site'
|
|
@@ -175,10 +175,10 @@ async function factory (pkgName) {
|
|
|
175
175
|
|
|
176
176
|
start = async () => {
|
|
177
177
|
const { getModel } = this.app.dobo
|
|
178
|
-
if (this.config.
|
|
178
|
+
if (this.config.xSiteAdmins.length === 0) {
|
|
179
179
|
const site = await getModel('SumbaSite').findOneRecord({ query: { alias: 'default' } }, { noMagic: true })
|
|
180
180
|
const user = await getModel('SumbaUser').findOneRecord({ query: { username: 'admin', siteId: site.id } }, { noMagic: true })
|
|
181
|
-
this.config.
|
|
181
|
+
this.config.xSiteAdmins.push(`${site.alias}:${user.username}`)
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
@@ -556,7 +556,7 @@ async function factory (pkgName) {
|
|
|
556
556
|
|
|
557
557
|
getRouteGuards = async (reread) => {
|
|
558
558
|
const { routePath } = this.app.waibu
|
|
559
|
-
const {
|
|
559
|
+
const { orderBy } = this.app.lib._
|
|
560
560
|
const { isSet } = this.app.lib.aneka
|
|
561
561
|
if (!reread) return this.routeGuards
|
|
562
562
|
|
|
@@ -571,9 +571,13 @@ async function factory (pkgName) {
|
|
|
571
571
|
delete item.siteId
|
|
572
572
|
return item
|
|
573
573
|
})
|
|
574
|
-
this.routeGuards[type] = orderBy(
|
|
575
|
-
|
|
576
|
-
|
|
574
|
+
this.routeGuards[type] = orderBy(result[type].filter(item => {
|
|
575
|
+
try {
|
|
576
|
+
item.path = routePath(item.path)
|
|
577
|
+
return true
|
|
578
|
+
} catch (err) {
|
|
579
|
+
return false
|
|
580
|
+
}
|
|
577
581
|
}), ['weight', 'path'], ['desc', 'asc'])
|
|
578
582
|
}
|
|
579
583
|
return this.routeGuards
|
package/lib/get-user.js
CHANGED
|
@@ -30,7 +30,7 @@ export async function mergeTeam (user, req) {
|
|
|
30
30
|
user.teams.push(item)
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
user.isXSiteAdmin = this.config.
|
|
33
|
+
user.isXSiteAdmin = this.config.xSiteAdmins.includes(`${req.site.alias}:${user.username}`)
|
|
34
34
|
user.isAdmin = user.teams.some(t => t.alias === 'administrator')
|
|
35
35
|
for (const field of this.unsafeUserFields) {
|
|
36
36
|
delete user[field]
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-05-28
|
|
4
|
+
|
|
5
|
+
- [2.26.0] Change hooks to be written in one ```hook.js``` file
|
|
6
|
+
- [2.26.0] Change model schemas to be written in one ```model.js``` file
|
|
7
|
+
|
|
8
|
+
## 2026-05-25
|
|
9
|
+
|
|
10
|
+
- [2.25.1] Bug fix in several places because name changing ```crossSiteAdmins``` to ```xSiteAdmins```
|
|
11
|
+
|
|
3
12
|
## 2026-05-22
|
|
4
13
|
|
|
5
14
|
- [2.25.0] Reorganize admin menu layout & order
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
|
|
3
|
-
async function afterReadConfig (file, result, options) {
|
|
4
|
-
const base = path.basename(file, path.extname(file))
|
|
5
|
-
// rewrite fixtures
|
|
6
|
-
if (!(base === 'route-guard' && Array.isArray(result) && file.includes('/fixture/'))) return
|
|
7
|
-
for (const res of result) {
|
|
8
|
-
if (res.path.slice(0, 2) === ':/') res.path = options.sourceNs + res.path
|
|
9
|
-
res.path = res.path.replaceAll('{ns}', options.sourceNs)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default afterReadConfig
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
async function afterCreateRecord (body, rec, options = {}) {
|
|
2
|
-
const { data } = rec
|
|
3
|
-
const { req } = options
|
|
4
|
-
const { get } = this.app.lib._
|
|
5
|
-
const t = get(req, 't', this.t)
|
|
6
|
-
const to = `${data.firstName} ${data.lastName} <${data.email}>`
|
|
7
|
-
let bcc
|
|
8
|
-
if (req.site) bcc = req.site.email
|
|
9
|
-
const subject = t('contactForm')
|
|
10
|
-
const payload = { to, bcc, subject, data }
|
|
11
|
-
await this.sendMail(
|
|
12
|
-
'sumba.template:/_mail/help-contact-form.html',
|
|
13
|
-
{ payload, options, source: this.ns }
|
|
14
|
-
)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default afterCreateRecord
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const beforeCreateRecord = {
|
|
2
|
-
level: 1000,
|
|
3
|
-
handler: async function (body, options = {}) {
|
|
4
|
-
const { get, isEmpty } = this.app.lib._
|
|
5
|
-
const user = get(options, 'req.user')
|
|
6
|
-
if (user) {
|
|
7
|
-
if (isEmpty(body.firstName)) body.firstName = user.firstName
|
|
8
|
-
if (isEmpty(body.lastName)) body.lastName = user.firstName
|
|
9
|
-
if (isEmpty(body.email)) body.email = user.email
|
|
10
|
-
}
|
|
11
|
-
if (isEmpty(body.category)) body.category = 'MISC'
|
|
12
|
-
options.checksumId = true
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default beforeCreateRecord
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createRefs, getAllFixtures } from '../../../lib/create-new-site.js'
|
|
2
|
-
|
|
3
|
-
async function afterCreateRecord (body, result, options) {
|
|
4
|
-
const fixtures = await getAllFixtures.call(this, result.data.alias)
|
|
5
|
-
await createRefs.call(this, result.data, fixtures, options)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default afterCreateRecord
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { removeRefs } from '../../../lib/remove-site.js'
|
|
2
|
-
import { clearCache } from './dobo.sumba-site@after-update-record.js'
|
|
3
|
-
|
|
4
|
-
async function afterRemoveRecord (id, result, options) {
|
|
5
|
-
await removeRefs.call(this, result.oldData, options)
|
|
6
|
-
await clearCache.call(this, id, result)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default afterRemoveRecord
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export async function clearCache (id, result) {
|
|
2
|
-
if (!this.app.bajoCache) return
|
|
3
|
-
const { clear } = this.app.bajoCache ?? {}
|
|
4
|
-
const { get } = this.app.lib._
|
|
5
|
-
await clear({ key: 'dobo|SumbaSite|getSite|default' })
|
|
6
|
-
await clear({ key: `dobo|SumbaSite|getSite|multiSite|${id}` })
|
|
7
|
-
await clear({ key: `dobo|SumbaSite|getSite|multiSite|${get(result, 'data.hostname', get(result, 'oldData.hostname'))}` })
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async function afterUpdateRecord (id, input, result, opts) {
|
|
11
|
-
await clearCache.call(this, id, result)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default afterUpdateRecord
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
async function afterTransaction (action, ...args) {
|
|
2
|
-
if (!['createRecord', 'updateRecord', 'removeRecord'].includes(action)) return
|
|
3
|
-
await this.getRouteGuards(true)
|
|
4
|
-
await this.getModelGuards(true)
|
|
5
|
-
await this.getAttribGuards(true)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default afterTransaction
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
async function afterCreateRecord (body, rec, options = {}) {
|
|
2
|
-
const { data } = rec
|
|
3
|
-
const { req } = options
|
|
4
|
-
const { get } = this.app.lib._
|
|
5
|
-
const t = get(req, 't', this.t)
|
|
6
|
-
const to = `${data.firstName} ${data.lastName} <${data.email}>`
|
|
7
|
-
const subject = t('newUserSignup')
|
|
8
|
-
const payload = { to, subject, data }
|
|
9
|
-
await this.sendMail(
|
|
10
|
-
`sumba.template:/_mail/user-signup-success${data.status === 'ACTIVE' ? '-active' : ''}.html`,
|
|
11
|
-
{ payload, options, source: this.ns }
|
|
12
|
-
)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default afterCreateRecord
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
async function afterRecordValidation (body, options) {
|
|
2
|
-
const { isBcrypt, hash } = this.app.bajoExtra
|
|
3
|
-
const { has } = this.app.lib._
|
|
4
|
-
|
|
5
|
-
if (has(body, 'password') && !isBcrypt(body.password)) body.password = await hash(body.password, 'bcrypt')
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default afterRecordValidation
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export async function clearCache (id, result) {
|
|
2
|
-
if (!this.app.bajoCache) return
|
|
3
|
-
const { clear } = this.app.bajoCache ?? {}
|
|
4
|
-
const { get } = this.app.lib._
|
|
5
|
-
const token = get(result, 'data.token', get(result, 'oldData.token', ''))
|
|
6
|
-
await clear({ key: `dobo|SumbaUser|getUserById|${id}` })
|
|
7
|
-
await clear({ key: `dobo|SumbaUser|getUserByToken|${token}` })
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async function afterUpdateRecord (id, body, rec, options = {}) {
|
|
11
|
-
const { data, oldData } = rec
|
|
12
|
-
const { req } = options
|
|
13
|
-
const { get } = this.app.lib._
|
|
14
|
-
const t = get(req, 't', this.t)
|
|
15
|
-
const to = `${data.firstName} ${data.lastName} <${data.email}>`
|
|
16
|
-
const source = this.ns
|
|
17
|
-
|
|
18
|
-
await clearCache.call(this, id, rec)
|
|
19
|
-
|
|
20
|
-
let subject
|
|
21
|
-
const payload = { to, subject, data }
|
|
22
|
-
|
|
23
|
-
if (oldData.status === 'UNVERIFIED' && data.status === 'ACTIVE') {
|
|
24
|
-
payload.subject = t('userActivation')
|
|
25
|
-
await this.sendMail(
|
|
26
|
-
'sumba.template:/_mail/user-activation-success.html',
|
|
27
|
-
{ payload, options, source }
|
|
28
|
-
)
|
|
29
|
-
} else if (oldData.token !== data.token) {
|
|
30
|
-
payload.subject = t('resetApiKey')
|
|
31
|
-
await this.sendMail(
|
|
32
|
-
'sumba.template:/_mail/mystuff-reset-api-key.html',
|
|
33
|
-
{ payload, options, source }
|
|
34
|
-
)
|
|
35
|
-
} else if (body.password) {
|
|
36
|
-
payload.subject = t('changePassword')
|
|
37
|
-
await this.sendMail(
|
|
38
|
-
'sumba.template:/_mail/mystuff-change-password.html',
|
|
39
|
-
{ payload, options, source }
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default afterUpdateRecord
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
async function beforeRecordValidation (body, options = {}) {
|
|
2
|
-
const { set } = this.app.lib._
|
|
3
|
-
const password = await this.passwordRule(options.req)
|
|
4
|
-
const rule = { password }
|
|
5
|
-
set(options, 'validation.params.rule', rule)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default beforeRecordValidation
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const doboBeforeDriverCreateRecord = {
|
|
2
|
-
level: 1000,
|
|
3
|
-
handler: async function (model, body, options = {}) {
|
|
4
|
-
const { get } = this.app.lib._
|
|
5
|
-
const { isSet } = this.app.lib.aneka
|
|
6
|
-
const { req } = options
|
|
7
|
-
if (options.noAutoFilter || !req || get(req, 'routeOptions.config.xSite')) return
|
|
8
|
-
const item = { siteId: 'site.id', userId: 'user.id' }
|
|
9
|
-
for (const i in item) {
|
|
10
|
-
const rec = get(req, item[i])
|
|
11
|
-
const field = model.getProperty(i)
|
|
12
|
-
if (rec && field && !isSet(body[i])) body[i] = field.type === 'string' ? (rec + '') : rec
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default doboBeforeDriverCreateRecord
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { rebuildFilter } from './dobo@before-driver-find-record.js'
|
|
2
|
-
|
|
3
|
-
const doboBeforeDriverFindAllRecord = {
|
|
4
|
-
level: 1000,
|
|
5
|
-
handler: async function (model, filter, options) {
|
|
6
|
-
const { req } = options
|
|
7
|
-
const { isEmpty } = this.app.lib._
|
|
8
|
-
if (options.noAutoFilter || !req || isEmpty(req.site)) return
|
|
9
|
-
await rebuildFilter.call(this, model, filter, options)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default doboBeforeDriverFindAllRecord
|