sumba 2.25.1 → 2.26.1
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/model.js +215 -0
- package/extend/dobo/model.json +214 -0
- package/index.js +5 -3
- package/lib/util.js +8 -8
- package/package.json +1 -1
- package/wiki/CHANGES.md +10 -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 -8
- package/extend/bajo/hook/dobo@before-driver-find-record.js +0 -133
- package/extend/bajo/hook/dobo@before-driver-get-record.js +0 -23
- 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
|
@@ -377,7 +377,7 @@ async function factory (pkgName) {
|
|
|
377
377
|
return true
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
checkPathsByRoute = ({ paths = [], teamIds = [], guards = [] }) => {
|
|
380
|
+
checkPathsByRoute = ({ req, paths = [], teamIds = [], guards = [] }) => {
|
|
381
381
|
const { includes } = this.app.lib.aneka
|
|
382
382
|
const { outmatch } = this.app.lib
|
|
383
383
|
|
|
@@ -385,8 +385,10 @@ async function factory (pkgName) {
|
|
|
385
385
|
const matchPath = outmatch(item.path)
|
|
386
386
|
for (const path of paths) {
|
|
387
387
|
if (matchPath(path)) {
|
|
388
|
-
if (includes(
|
|
389
|
-
|
|
388
|
+
if (item.methods.includes(req.method)) {
|
|
389
|
+
if (includes(teamIds, item.teamIds)) return item
|
|
390
|
+
if (teamIds.length === 0) return item
|
|
391
|
+
}
|
|
390
392
|
}
|
|
391
393
|
}
|
|
392
394
|
}
|
package/lib/util.js
CHANGED
|
@@ -122,28 +122,28 @@ export async function checkUserId (req, reply, source) {
|
|
|
122
122
|
const globalGuards = guards.global.filter(item => item.siteIds.includes(req.site.id + ''))
|
|
123
123
|
const localGuards = guards.local.filter(item => item.siteIds.includes(req.site.id + ''))
|
|
124
124
|
// find anonymousPath
|
|
125
|
-
anonymousPath = await this.checkPathsByRoute({ paths, guards: localGuards.filter(item => item.anonymous && !item.negation) })
|
|
125
|
+
anonymousPath = await this.checkPathsByRoute({ req, paths, guards: localGuards.filter(item => item.anonymous && !item.negation) })
|
|
126
126
|
if (anonymousPath) {
|
|
127
|
-
const neg = await this.checkPathsByRoute({ paths, guards: localGuards.filter(item => item.anonymous && item.negation) })
|
|
127
|
+
const neg = await this.checkPathsByRoute({ req, paths, guards: localGuards.filter(item => item.anonymous && item.negation) })
|
|
128
128
|
if (neg) anonymousPath = undefined
|
|
129
129
|
}
|
|
130
130
|
if (!anonymousPath) {
|
|
131
|
-
anonymousPath = await this.checkPathsByRoute({ paths, guards: globalGuards.filter(item => item.anonymous && !item.negation) })
|
|
131
|
+
anonymousPath = await this.checkPathsByRoute({ req, paths, guards: globalGuards.filter(item => item.anonymous && !item.negation) })
|
|
132
132
|
if (anonymousPath) {
|
|
133
|
-
const neg = await this.checkPathsByRoute({ paths, guards: globalGuards.filter(item => item.anonymous && item.negation) })
|
|
133
|
+
const neg = await this.checkPathsByRoute({ req, paths, guards: globalGuards.filter(item => item.anonymous && item.negation) })
|
|
134
134
|
if (neg) anonymousPath = undefined
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
// find securePath
|
|
138
|
-
securePath = await this.checkPathsByRoute({ paths, guards: localGuards.filter(item => !item.anonymous && !item.negation) })
|
|
138
|
+
securePath = await this.checkPathsByRoute({ req, paths, guards: localGuards.filter(item => !item.anonymous && !item.negation) })
|
|
139
139
|
if (securePath) {
|
|
140
|
-
const neg = await this.checkPathsByRoute({ paths, guards: localGuards.filter(item => !item.anonymous && item.negation) })
|
|
140
|
+
const neg = await this.checkPathsByRoute({ req, paths, guards: localGuards.filter(item => !item.anonymous && item.negation) })
|
|
141
141
|
if (neg) securePath = undefined
|
|
142
142
|
}
|
|
143
143
|
if (!securePath) {
|
|
144
|
-
securePath = await this.checkPathsByRoute({ paths, guards: globalGuards.filter(item => !item.anonymous && !item.negation) })
|
|
144
|
+
securePath = await this.checkPathsByRoute({ req, paths, guards: globalGuards.filter(item => !item.anonymous && !item.negation) })
|
|
145
145
|
if (securePath) {
|
|
146
|
-
const neg = await this.checkPathsByRoute({ paths, guards: globalGuards.filter(item => !item.anonymous && item.negation) })
|
|
146
|
+
const neg = await this.checkPathsByRoute({ req, paths, guards: globalGuards.filter(item => !item.anonymous && item.negation) })
|
|
147
147
|
if (neg) securePath = undefined
|
|
148
148
|
}
|
|
149
149
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-05-29
|
|
4
|
+
|
|
5
|
+
- [2.26.1] Bug fix in ```util.js```
|
|
6
|
+
- [2.26.1] Bug fix in ```checkPathsByRoute()```
|
|
7
|
+
|
|
8
|
+
## 2026-05-28
|
|
9
|
+
|
|
10
|
+
- [2.26.0] Change hooks to be written in one ```hook.js``` file
|
|
11
|
+
- [2.26.0] Change model schemas to be written in one ```model.js``` file
|
|
12
|
+
|
|
3
13
|
## 2026-05-25
|
|
4
14
|
|
|
5
15
|
- [2.25.1] Bug fix in several places because name changing ```crossSiteAdmins``` to ```xSiteAdmins```
|
|
@@ -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
|