@waline/vercel 1.12.0 → 1.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waline/vercel",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "vercel server for waline comment system",
5
5
  "repository": "https://github.com/walinejs/waline",
6
6
  "license": "MIT",
@@ -0,0 +1,46 @@
1
+ const jwt = require('jsonwebtoken');
2
+ const BaseRest = require('../rest');
3
+
4
+ module.exports = class extends BaseRest {
5
+ async putAction() {
6
+ const {
7
+ SMTP_HOST,
8
+ SMTP_SERVICE,
9
+ SENDER_EMAIL,
10
+ SENDER_NAME,
11
+ SMTP_USER,
12
+ SITE_NAME,
13
+ } = process.env;
14
+ const hasMailServie = SMTP_HOST || SMTP_SERVICE;
15
+ if (!hasMailServie) {
16
+ return this.fail();
17
+ }
18
+
19
+ const { email } = this.post();
20
+ const userModel = this.service(
21
+ `storage/${this.config('storage')}`,
22
+ 'Users'
23
+ );
24
+ const user = await userModel.select({ email });
25
+ if (think.isEmpty(user)) {
26
+ return this.fail();
27
+ }
28
+
29
+ const notify = this.service('notify');
30
+ const { protocol, host } = this.ctx;
31
+ const token = jwt.sign(user[0].email, this.config('jwtKey'));
32
+ const profileUrl = `${protocol}://${host}/ui/profile?token=${token}`;
33
+
34
+ await notify.transporter.sendMail({
35
+ from:
36
+ SENDER_EMAIL && SENDER_NAME
37
+ ? `"${SENDER_NAME}" <${SENDER_EMAIL}>`
38
+ : SMTP_USER,
39
+ to: user[0].email,
40
+ subject: `【${SITE_NAME || 'Waline'}】Reset Password`,
41
+ html: `Please click <a href="${profileUrl}">${profileUrl}</a> to login and change your password as soon as possible!`,
42
+ });
43
+
44
+ return this.success();
45
+ }
46
+ };
@@ -0,0 +1,11 @@
1
+ const Base = require('../base');
2
+
3
+ module.exports = class extends Base {
4
+ async putAction() {
5
+ this.rules = {
6
+ email: {
7
+ required: true,
8
+ },
9
+ };
10
+ }
11
+ };
@@ -335,7 +335,7 @@ module.exports = class extends think.Service {
335
335
  title = nunjucks.renderString(title, data);
336
336
  content = nunjucks.renderString(
337
337
  think.config('DiscordTemplate') ||
338
- `💬 {{site.name|safe}}的文章《{{postName}}》有新评论啦
338
+ `💬 {{site.name|safe}} 有新评论啦
339
339
  【评论者昵称】:{{self.nick}}
340
340
  【评论者邮箱】:{{self.mail}}
341
341
  【内容】:{{self.comment}}