free-be-account 0.0.15 → 0.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.
- package/index.js +170 -49
- package/package-lock.json +1539 -0
- package/package.json +13 -8
- package/routers/mgmt/route.js +10 -11
- package/routers/uc/info/route.js +5 -5
- package/routers/uc/noty/index.js +4 -0
- package/routers/uc/noty/route.js +61 -0
- package/sms/index.js +10 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "free-be-account",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -9,14 +9,19 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@alicloud/pop-core": "^1.7.13",
|
|
12
|
-
"axios": "^1.
|
|
13
|
-
"bcrypt": "^5.1.
|
|
14
|
-
"
|
|
15
|
-
"js
|
|
16
|
-
"
|
|
17
|
-
"
|
|
12
|
+
"axios": "^1.7.7",
|
|
13
|
+
"bcrypt": "^5.1.1",
|
|
14
|
+
"connect-redis": "^7.1.1",
|
|
15
|
+
"crypto-js": "^4.2.0",
|
|
16
|
+
"express-session": "^1.18.1",
|
|
17
|
+
"js-md5": "^0.8.3",
|
|
18
|
+
"minimatch": "^10.0.1",
|
|
19
|
+
"nodemailer": "^6.9.16",
|
|
20
|
+
"passport": "^0.7.0",
|
|
18
21
|
"passport-local": "^1.0.0",
|
|
22
|
+
"semver": "^7.6.3",
|
|
19
23
|
"svg-captcha": "^1.4.0",
|
|
20
|
-
"
|
|
24
|
+
"tar": "^7.4.3",
|
|
25
|
+
"uuid": "^11.0.2"
|
|
21
26
|
}
|
|
22
27
|
}
|
package/routers/mgmt/route.js
CHANGED
|
@@ -4,26 +4,26 @@ const router = express.Router();
|
|
|
4
4
|
const { AccountAuditStatus } = require('../../enum');
|
|
5
5
|
const { clearPermission, encryptPwd, crypto } = require('../../utils');
|
|
6
6
|
|
|
7
|
-
// TODO: i18n translate
|
|
8
7
|
const accountFilters = [
|
|
8
|
+
{
|
|
9
|
+
Name: 'id',
|
|
10
|
+
Type: 'String',
|
|
11
|
+
Info: {
|
|
12
|
+
Separate: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
9
15
|
{
|
|
10
16
|
Name: 'LastUpdateDate',
|
|
11
17
|
Type: 'DateRange',
|
|
12
|
-
Label: '更新日期',
|
|
13
|
-
Placeholder: '请选择',
|
|
14
18
|
},
|
|
15
19
|
{
|
|
16
20
|
Name: 'Enabled',
|
|
17
21
|
Type: 'Select',
|
|
18
|
-
Label: '激活状态',
|
|
19
|
-
Placeholder: '请选择',
|
|
20
22
|
Options: [
|
|
21
23
|
{
|
|
22
|
-
Label: '已激活',
|
|
23
24
|
Value: true,
|
|
24
25
|
},
|
|
25
26
|
{
|
|
26
|
-
Label: '未激活',
|
|
27
27
|
Value: false,
|
|
28
28
|
},
|
|
29
29
|
],
|
|
@@ -31,22 +31,18 @@ const accountFilters = [
|
|
|
31
31
|
{
|
|
32
32
|
Name: 'Profile.Name',
|
|
33
33
|
Type: 'String',
|
|
34
|
-
Label: '姓名',
|
|
35
34
|
},
|
|
36
35
|
{
|
|
37
36
|
Name: 'Profile.Title',
|
|
38
37
|
Type: 'String',
|
|
39
|
-
Label: '职务',
|
|
40
38
|
},
|
|
41
39
|
{
|
|
42
40
|
Name: 'PhoneNumber',
|
|
43
41
|
Type: 'String',
|
|
44
|
-
Label: '手机号',
|
|
45
42
|
},
|
|
46
43
|
{
|
|
47
44
|
Name: 'UserName',
|
|
48
45
|
Type: 'String',
|
|
49
|
-
Label: '用户名',
|
|
50
46
|
},
|
|
51
47
|
];
|
|
52
48
|
|
|
@@ -94,6 +90,9 @@ router.get('/', async (req, res, next) => {
|
|
|
94
90
|
}
|
|
95
91
|
}
|
|
96
92
|
}
|
|
93
|
+
|
|
94
|
+
doc.Profile = doc.Profile || {};
|
|
95
|
+
doc.Profile.Name = doc.Profile.Name || doc.UserName || '';
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
}));
|
package/routers/uc/info/route.js
CHANGED
|
@@ -91,12 +91,12 @@ router.post('/submit',
|
|
|
91
91
|
|
|
92
92
|
if (router.mdl.config.accountRequireAudit) {
|
|
93
93
|
res.locals.body.Status = router.mdl.AccountAuditStatus.Auditing;
|
|
94
|
-
}
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
// set to default permission
|
|
96
|
+
const p = router.mdl.config.accountDefaultPermissions;
|
|
97
|
+
res.app.modules.account.utils.clearPermission(p);
|
|
98
|
+
res.locals.body.Permission = p;
|
|
99
|
+
}
|
|
100
100
|
|
|
101
101
|
res.locals.filter = { id: req.user.id };
|
|
102
102
|
res.locals.fields = [
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const express = require(require('path').resolve('./') + "/node_modules/express");
|
|
2
|
+
const router = express.Router();
|
|
3
|
+
|
|
4
|
+
router.get('/count',
|
|
5
|
+
async (req, res, next) => {
|
|
6
|
+
const count = await res.app.models.system_notification.countDocuments({
|
|
7
|
+
User: req.user.id,
|
|
8
|
+
Read: false,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
res.addData({
|
|
12
|
+
count,
|
|
13
|
+
}, true);
|
|
14
|
+
|
|
15
|
+
return next();
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
router.get('/',
|
|
20
|
+
(req, res, next) => {
|
|
21
|
+
res.locals.filter = {
|
|
22
|
+
User: req.user.id,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
res.locals.fields = [
|
|
26
|
+
'id',
|
|
27
|
+
'CreatedDate',
|
|
28
|
+
|
|
29
|
+
'Title',
|
|
30
|
+
'Content',
|
|
31
|
+
'Read',
|
|
32
|
+
'Category',
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
return next();
|
|
36
|
+
},
|
|
37
|
+
router.FindDocuments('system_notification'),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
router.put('/read/:id',
|
|
41
|
+
(req, res, next) => {
|
|
42
|
+
res.locals.filter = {
|
|
43
|
+
id: req.params.id,
|
|
44
|
+
User: req.user.id,
|
|
45
|
+
Read: false,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
res.locals.fields = [
|
|
49
|
+
'Read',
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
res.locals.body = {
|
|
53
|
+
Read: true,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return next();
|
|
57
|
+
},
|
|
58
|
+
router.UpdateDocument('system_notification'),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
module.exports = router;
|
package/sms/index.js
CHANGED
|
@@ -9,7 +9,7 @@ if (fs.existsSync(path.resolve(__dirname, '../../../global.js'))) {
|
|
|
9
9
|
global = require('../../../global');
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
let MAIL_TRANS =
|
|
12
|
+
let MAIL_TRANS = {};
|
|
13
13
|
|
|
14
14
|
function _generateMSG (f = '4n') {
|
|
15
15
|
if (typeof f !== 'string' || f.length < 2) {
|
|
@@ -95,7 +95,7 @@ const _sms_lib = {
|
|
|
95
95
|
send: async function(k, p, v) {
|
|
96
96
|
if(!k || !k.host || !k.secret || !k.mail || !k.from || !k.title) throw new Error('MMail configuration incorrect!');
|
|
97
97
|
|
|
98
|
-
MAIL_TRANS = MAIL_TRANS || nodemailer.createTransport({
|
|
98
|
+
MAIL_TRANS[k.mail] = MAIL_TRANS[k.mail] || nodemailer.createTransport({
|
|
99
99
|
host: k.host,
|
|
100
100
|
secureConnection: true,
|
|
101
101
|
port: 465,
|
|
@@ -109,7 +109,7 @@ const _sms_lib = {
|
|
|
109
109
|
const result = await MAIL_TRANS.sendMail({
|
|
110
110
|
from: k.from,
|
|
111
111
|
to: p,
|
|
112
|
-
subject: k.title,
|
|
112
|
+
subject: typeof k.title === 'function' ? k.title(v) : k.title,
|
|
113
113
|
html: typeof k.template === 'function' ? k.template(v) : k.template,
|
|
114
114
|
envelope: {
|
|
115
115
|
from: k.from,
|
|
@@ -182,8 +182,14 @@ module.exports = (app) => ({
|
|
|
182
182
|
let v = _generateMSG(f);
|
|
183
183
|
return await this.send(p, v, c, t);
|
|
184
184
|
},
|
|
185
|
-
verify: async function (p, v) {
|
|
185
|
+
verify: async function (p, v, del) {
|
|
186
186
|
const cached = await app.cache.get(p);
|
|
187
|
+
|
|
188
|
+
// clear cache if the code is correct
|
|
189
|
+
if (del && cached === v) {
|
|
190
|
+
await app.cache.del(p);
|
|
191
|
+
}
|
|
192
|
+
|
|
187
193
|
return cached === v;
|
|
188
194
|
}
|
|
189
195
|
})
|