free-be-account 0.0.16 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-be-account",
3
- "version": "0.0.16",
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.6.8",
12
+ "axios": "^1.7.7",
13
13
  "bcrypt": "^5.1.1",
14
+ "connect-redis": "^7.1.1",
14
15
  "crypto-js": "^4.2.0",
15
- "js-md5": "^0.7.3",
16
- "nodemailer": "^6.9.13",
17
- "passport": "^0.6.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
- "uuid": "^9.0.1"
24
+ "tar": "^7.4.3",
25
+ "uuid": "^11.0.2"
21
26
  }
22
27
  }
@@ -90,6 +90,9 @@ router.get('/', async (req, res, next) => {
90
90
  }
91
91
  }
92
92
  }
93
+
94
+ doc.Profile = doc.Profile || {};
95
+ doc.Profile.Name = doc.Profile.Name || doc.UserName || '';
93
96
  }
94
97
  }
95
98
  }));
@@ -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
- // set to default permission
97
- const p = router.mdl.config.accountDefaultPermissions;
98
- res.app.modules.account.utils.clearPermission(p);
99
- res.locals.body.Permission = p;
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,4 @@
1
+ module.exports = {
2
+ title: '系统通知',
3
+ description: '',
4
+ };
@@ -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 = undefined;
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
  })