@webbio/strapi-plugin-page-builder 0.9.17-authentication → 0.9.19-authentication

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": "@webbio/strapi-plugin-page-builder",
3
- "version": "0.9.17-authentication",
3
+ "version": "0.9.19-authentication",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -7,21 +7,14 @@ interface SendOptions {
7
7
  to: string;
8
8
  subject: string;
9
9
  text: string;
10
- firstName: string;
11
- lastName: string;
12
- confirmationUrl?: string;
10
+ variables?: Record<string, string>;
13
11
  }
14
12
 
15
13
  export default {
16
14
  async sendMail(options: SendOptions) {
17
- const { from, to, subject, text, firstName, lastName, confirmationUrl } = options;
18
- const emailData = txtEmail({
19
- email: to,
20
- firstName: firstName,
21
- lastName: lastName,
22
- text: text,
23
- confirmationUrl: confirmationUrl
24
- });
15
+ const { from, to, subject, text, variables } = options;
16
+
17
+ const emailData = txtEmail(text, variables);
25
18
 
26
19
  try {
27
20
  const client = new AWS.SES();
@@ -54,8 +47,10 @@ export default {
54
47
  subject: foundUser.platform.platformEmails.adminEmail.subject,
55
48
  // @ts-ignore
56
49
  text: foundUser.platform.platformEmails.adminEmail.message,
57
- firstName: user.firstName,
58
- lastName: user.lastName
50
+ variables: {
51
+ firstName: user.firstName,
52
+ lastName: user.lastName
53
+ }
59
54
  });
60
55
  },
61
56
  async sendConfirmationEmail(user) {
@@ -75,7 +70,7 @@ export default {
75
70
  });
76
71
 
77
72
  // @ts-ignore
78
- const activateUrl = `${strapi.config.server.url}/api/page-builder/activate/${confirmationToken}`;
73
+ const confirmEmailUrl = `${strapi.config.server.url}/api/page-builder/activate/${confirmationToken}`;
79
74
 
80
75
  await this.sendMail({
81
76
  // @ts-ignore
@@ -85,9 +80,11 @@ export default {
85
80
  subject: foundUser.platform.platformEmails.accountCreatedMail.subject,
86
81
  // @ts-ignore
87
82
  text: foundUser.platform.platformEmails.accountCreatedMail.message,
88
- firstName: user.firstName,
89
- lastName: user.lastName,
90
- confirmationUrl: activateUrl
83
+ variables: {
84
+ firstName: user.firstName,
85
+ lastName: user.lastName,
86
+ confirmEmailUrl
87
+ }
91
88
  });
92
89
  }
93
90
  },
@@ -105,7 +102,8 @@ export default {
105
102
  });
106
103
 
107
104
  // @ts-ignore
108
- const activateUrl = `${user.platform.domain}/api/page-builder/reset/${resetPasswordToken}`;
105
+ const searchParams = new URLSearchParams({ token: resetPasswordToken });
106
+ const resetPasswordUrl = `${user.platform.domain}/reset-password/?${searchParams.toString()}`;
109
107
 
110
108
  await this.sendMail({
111
109
  // @ts-ignore
@@ -115,9 +113,11 @@ export default {
115
113
  subject: user.platform.platformEmails.resetPasswordMail.subject,
116
114
  // @ts-ignore
117
115
  text: user.platform.platformEmails.resetPasswordMail.message,
118
- firstName: user.firstName,
119
- lastName: user.lastName,
120
- confirmationUrl: activateUrl
116
+ variables: {
117
+ firstName: user.firstName,
118
+ lastName: user.lastName,
119
+ resetPasswordUrl
120
+ }
121
121
  });
122
122
  }
123
123
  }
@@ -1,7 +1,6 @@
1
1
  import Handlebars from 'handlebars';
2
- import { IMail } from './txtMail.interface';
3
2
 
4
- export const txtEmail = (mailData: IMail) => {
5
- const template = Handlebars.compile(mailData.text);
6
- return template(mailData);
3
+ export const txtEmail = (text: string, variables?: Record<string, string>) => {
4
+ const template = Handlebars.compile(text);
5
+ return template(variables);
7
6
  };