@webbio/strapi-plugin-page-builder 0.14.2-platform → 0.15.1-platform
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/dist/package.json +1 -1
- package/dist/server/bootstrap.js +7 -9
- package/dist/server/services/email.js +27 -27
- package/dist/server/services/private-content/components/platform-email.json +3 -0
- package/dist/server/services/private-content/graphql/resolvers/forgot-password.js +0 -2
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/server/bootstrap.ts +6 -8
- package/server/services/email.ts +40 -27
- package/server/services/private-content/components/platform-email.json +3 -0
- package/server/services/private-content/graphql/resolvers/forgot-password.ts +0 -2
package/dist/package.json
CHANGED
package/dist/server/bootstrap.js
CHANGED
|
@@ -28,23 +28,21 @@ exports.default = async ({ strapi }) => {
|
|
|
28
28
|
(_a = strapi.db) === null || _a === void 0 ? void 0 : _a.lifecycles.subscribe({
|
|
29
29
|
models: [constants_1.USER_PERMISSION_USER_PLUGIN],
|
|
30
30
|
async beforeUpdate(event) {
|
|
31
|
-
var _a;
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
32
32
|
if (event.params.data.id) {
|
|
33
|
-
const originalUserObject = await ((_a = strapi.entityService) === null || _a === void 0 ? void 0 : _a.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, event.params.data.id, {
|
|
33
|
+
const originalUserObject = (await ((_a = strapi.entityService) === null || _a === void 0 ? void 0 : _a.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, event.params.data.id, {
|
|
34
34
|
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
35
|
-
}));
|
|
35
|
+
})));
|
|
36
36
|
if (originalUserObject &&
|
|
37
37
|
event.params.data.activateUser &&
|
|
38
38
|
event.params.data.confirmed &&
|
|
39
39
|
!originalUserObject.confirmMailSend) {
|
|
40
40
|
await strapi.service(constants_1.PAGE_BUILDER_EMAIL_PLUGIN).sendMail({
|
|
41
|
-
|
|
42
|
-
from: originalUserObject.platform.platformEmails.accountAcceptedMail.fromEmail,
|
|
41
|
+
from: (_d = (_c = (_b = originalUserObject.platform) === null || _b === void 0 ? void 0 : _b.platformEmails) === null || _c === void 0 ? void 0 : _c.accountAcceptedMail) === null || _d === void 0 ? void 0 : _d.fromEmail,
|
|
43
42
|
to: event.params.data.email,
|
|
44
|
-
|
|
45
|
-
subject: originalUserObject.platform.platformEmails.accountAcceptedMail.subject,
|
|
46
|
-
|
|
47
|
-
text: originalUserObject.platform.platformEmails.accountAcceptedMail.message,
|
|
43
|
+
nameSender: (_g = (_f = (_e = originalUserObject.platform) === null || _e === void 0 ? void 0 : _e.platformEmails) === null || _f === void 0 ? void 0 : _f.accountAcceptedMail) === null || _g === void 0 ? void 0 : _g.nameSender,
|
|
44
|
+
subject: (_k = (_j = (_h = originalUserObject.platform) === null || _h === void 0 ? void 0 : _h.platformEmails) === null || _j === void 0 ? void 0 : _j.accountAcceptedMail) === null || _k === void 0 ? void 0 : _k.subject,
|
|
45
|
+
text: (_o = (_m = (_l = originalUserObject.platform) === null || _l === void 0 ? void 0 : _l.platformEmails) === null || _m === void 0 ? void 0 : _m.accountAcceptedMail) === null || _o === void 0 ? void 0 : _o.message,
|
|
48
46
|
firstName: event.params.data.firstName,
|
|
49
47
|
lastName: event.params.data.lastName
|
|
50
48
|
});
|
|
@@ -29,12 +29,13 @@ const constants_1 = require("../../shared/utils/constants");
|
|
|
29
29
|
const utils_1 = require("@strapi/utils");
|
|
30
30
|
exports.default = {
|
|
31
31
|
async sendMail(options) {
|
|
32
|
-
const { from, to, subject, text, variables } = options;
|
|
32
|
+
const { from, to, subject, text, variables, nameSender } = options;
|
|
33
33
|
const emailData = (0, txtMail_email_template_text_1.txtEmail)(text, variables);
|
|
34
|
+
const Source = nameSender ? `${nameSender} <${from}>` : from;
|
|
34
35
|
try {
|
|
35
36
|
const client = new AWS.SES();
|
|
36
37
|
await client.sendEmail({
|
|
37
|
-
Source
|
|
38
|
+
Source,
|
|
38
39
|
Destination: {
|
|
39
40
|
ToAddresses: [to]
|
|
40
41
|
},
|
|
@@ -52,17 +53,16 @@ exports.default = {
|
|
|
52
53
|
}
|
|
53
54
|
},
|
|
54
55
|
async sendAdminMail(user) {
|
|
55
|
-
|
|
56
|
+
var _a, _b, _c;
|
|
57
|
+
const foundUser = (await strapi.entityService.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
56
58
|
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
57
|
-
});
|
|
59
|
+
}));
|
|
60
|
+
console.log('HI', (_c = (_b = (_a = foundUser === null || foundUser === void 0 ? void 0 : foundUser.platform) === null || _a === void 0 ? void 0 : _a.platformEmails) === null || _b === void 0 ? void 0 : _b.adminEmail) === null || _c === void 0 ? void 0 : _c.fromEmail);
|
|
58
61
|
await this.sendMail({
|
|
59
|
-
// @ts-ignore we all love strapi typings
|
|
60
62
|
from: foundUser.platform.platformEmails.adminEmail.fromEmail,
|
|
61
|
-
// @ts-ignore
|
|
62
63
|
to: foundUser.platform.platformEmails.adminEmail.toEmail,
|
|
63
|
-
|
|
64
|
+
nameSender: user.platform.platformEmails.adminEmail.nameSender,
|
|
64
65
|
subject: foundUser.platform.platformEmails.adminEmail.subject,
|
|
65
|
-
// @ts-ignore
|
|
66
66
|
text: foundUser.platform.platformEmails.adminEmail.message,
|
|
67
67
|
variables: {
|
|
68
68
|
firstName: user.firstName,
|
|
@@ -71,33 +71,24 @@ exports.default = {
|
|
|
71
71
|
});
|
|
72
72
|
},
|
|
73
73
|
async sendConfirmationEmail(user) {
|
|
74
|
-
const foundUser = await strapi.entityService.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
74
|
+
const foundUser = (await strapi.entityService.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
75
75
|
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
76
|
-
});
|
|
76
|
+
}));
|
|
77
77
|
if (foundUser && foundUser.platform) {
|
|
78
78
|
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
79
|
-
const confirmationToken = await jwtService.issue(
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
{ userId: user.id, platformId: foundUser.platform.id }, { expiresIn: '1d' });
|
|
79
|
+
const confirmationToken = await jwtService.issue({ userId: user.id, platformId: foundUser.platform.id }, { expiresIn: '1d' });
|
|
82
80
|
await strapi.entityService.update(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
83
|
-
// @ts-ignore
|
|
84
81
|
data: { confirmationToken: confirmationToken }
|
|
85
82
|
});
|
|
86
|
-
// @ts-ignore
|
|
87
83
|
const confirmEmailUrl = `${strapi.config.server.url}/api/page-builder/activate/${confirmationToken}`;
|
|
88
84
|
await this.sendMail({
|
|
89
|
-
// @ts-ignore
|
|
90
85
|
from: foundUser.platform.platformEmails.accountCreatedMail.fromEmail,
|
|
91
|
-
// @ts-ignore
|
|
92
86
|
to: foundUser.email,
|
|
93
|
-
|
|
87
|
+
nameSender: user.platform.platformEmails.accountCreatedMail.nameSender,
|
|
94
88
|
subject: foundUser.platform.platformEmails.accountCreatedMail.subject,
|
|
95
|
-
// @ts-ignore
|
|
96
89
|
text: foundUser.platform.platformEmails.accountCreatedMail.message,
|
|
97
90
|
variables: {
|
|
98
|
-
// @ts-ignore
|
|
99
91
|
firstName: foundUser.firstName,
|
|
100
|
-
// @ts-ignore
|
|
101
92
|
lastName: foundUser.lastName,
|
|
102
93
|
confirmEmailUrl
|
|
103
94
|
}
|
|
@@ -109,18 +100,14 @@ exports.default = {
|
|
|
109
100
|
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
110
101
|
const resetPasswordToken = await jwtService.issue({ userId: user.id, platformId: user.platform.id }, { expiresIn: '1d' });
|
|
111
102
|
await strapi.entityService.update(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
112
|
-
// @ts-ignore
|
|
113
103
|
data: { resetPasswordToken }
|
|
114
104
|
});
|
|
115
|
-
|
|
116
|
-
const resetPasswordUrl = `${user.platform.domain}/wachtwoord-resetten/${resetPasswordToken}`;
|
|
105
|
+
const resetPasswordUrl = getResetPasswordUrl(user, resetPasswordToken);
|
|
117
106
|
await this.sendMail({
|
|
118
|
-
// @ts-ignore
|
|
119
107
|
from: user.platform.platformEmails.resetPasswordMail.fromEmail,
|
|
120
108
|
to: user.email,
|
|
121
|
-
|
|
109
|
+
nameSender: user.platform.platformEmails.resetPasswordMail.nameSender,
|
|
122
110
|
subject: user.platform.platformEmails.resetPasswordMail.subject,
|
|
123
|
-
// @ts-ignore
|
|
124
111
|
text: user.platform.platformEmails.resetPasswordMail.message,
|
|
125
112
|
variables: {
|
|
126
113
|
firstName: user === null || user === void 0 ? void 0 : user.firstName,
|
|
@@ -131,3 +118,16 @@ exports.default = {
|
|
|
131
118
|
}
|
|
132
119
|
}
|
|
133
120
|
};
|
|
121
|
+
const getResetPasswordUrl = (user, resetPasswordToken) => {
|
|
122
|
+
if (!user || !(user === null || user === void 0 ? void 0 : user.platform)) {
|
|
123
|
+
return '';
|
|
124
|
+
}
|
|
125
|
+
if (user.platform.platformEmails.resetPasswordUrl &&
|
|
126
|
+
user.platform.platformEmails.resetPasswordUrl.includes('{{resetPasswordToken}}')) {
|
|
127
|
+
const replacedTokens = user.platform.platformEmails.resetPasswordUrl
|
|
128
|
+
.replace('{{domain}}', user.platform.domain)
|
|
129
|
+
.replace('{{resetPasswordToken}}', resetPasswordToken);
|
|
130
|
+
return replacedTokens;
|
|
131
|
+
}
|
|
132
|
+
return `${user.platform.domain}/wachtwoord-resetten/${resetPasswordToken}`;
|
|
133
|
+
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.platformForgotPassword = void 0;
|
|
4
|
-
const utils_1 = require("@strapi/utils");
|
|
5
4
|
const constants_1 = require("../../constants");
|
|
6
5
|
const schemas_1 = require("../../schemas");
|
|
7
|
-
const { UnauthorizedError } = utils_1.errors;
|
|
8
6
|
exports.platformForgotPassword = {
|
|
9
7
|
async resolve(parent, args, context) {
|
|
10
8
|
await (0, schemas_1.validateForgotPasswordSchema)(args.input);
|