@webbio/strapi-plugin-page-builder 0.15.1-platform → 0.15.3-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/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +1 -1
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +1 -1
- package/admin/src/components/EditView/Details/index.tsx +1 -1
- package/dist/package.json +1 -1
- package/dist/server/bootstrap.js +24 -17
- package/dist/server/services/email.js +84 -57
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/server/bootstrap.ts +30 -23
- package/server/services/email.ts +93 -70
package/package.json
CHANGED
package/server/bootstrap.ts
CHANGED
|
@@ -36,30 +36,37 @@ export default async ({ strapi }: { strapi: Strapi }) => {
|
|
|
36
36
|
models: [USER_PERMISSION_USER_PLUGIN],
|
|
37
37
|
async beforeUpdate(event) {
|
|
38
38
|
if (event.params.data.id) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
try {
|
|
40
|
+
const originalUserObject = (await strapi.entityService?.findOne(
|
|
41
|
+
USER_PERMISSION_USER_PLUGIN,
|
|
42
|
+
event.params.data.id,
|
|
43
|
+
{
|
|
44
|
+
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
45
|
+
}
|
|
46
|
+
)) as Record<string, any>;
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
if (
|
|
49
|
+
originalUserObject &&
|
|
50
|
+
event.params.data.activateUser &&
|
|
51
|
+
event.params.data.confirmed &&
|
|
52
|
+
!originalUserObject.confirmMailSend
|
|
53
|
+
) {
|
|
54
|
+
const send = await strapi.service(PAGE_BUILDER_EMAIL_PLUGIN).sendMail({
|
|
55
|
+
from: originalUserObject.platform?.platformEmails?.accountAcceptedMail?.fromEmail,
|
|
56
|
+
to: event.params.data.email,
|
|
57
|
+
nameSender: originalUserObject.platform?.platformEmails?.accountAcceptedMail?.nameSender,
|
|
58
|
+
subject: originalUserObject.platform?.platformEmails?.accountAcceptedMail?.subject,
|
|
59
|
+
text: originalUserObject.platform?.platformEmails?.accountAcceptedMail?.message,
|
|
60
|
+
firstName: event.params.data.firstName,
|
|
61
|
+
lastName: event.params.data.lastName
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (send) {
|
|
65
|
+
event.params.data.confirmMailSend = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.error('Send Account Approved Mail Error:', e);
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
72
|
}
|
package/server/services/email.ts
CHANGED
|
@@ -35,88 +35,111 @@ export default {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
+
|
|
39
|
+
return true;
|
|
38
40
|
} catch (error) {
|
|
39
41
|
console.error(error);
|
|
40
42
|
throw new errors.ApplicationError('Failed to send email', error);
|
|
41
43
|
}
|
|
42
44
|
},
|
|
43
45
|
async sendAdminMail(user) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log('HI', foundUser?.platform?.platformEmails?.adminEmail?.fromEmail);
|
|
49
|
-
|
|
50
|
-
await this.sendMail({
|
|
51
|
-
from: foundUser.platform.platformEmails.adminEmail.fromEmail,
|
|
52
|
-
to: foundUser.platform.platformEmails.adminEmail.toEmail,
|
|
53
|
-
nameSender: user.platform.platformEmails.adminEmail.nameSender,
|
|
54
|
-
subject: foundUser.platform.platformEmails.adminEmail.subject,
|
|
55
|
-
text: foundUser.platform.platformEmails.adminEmail.message,
|
|
56
|
-
variables: {
|
|
57
|
-
firstName: user.firstName,
|
|
58
|
-
lastName: user.lastName
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
async sendConfirmationEmail(user) {
|
|
63
|
-
const foundUser = (await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
64
|
-
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
65
|
-
})) as Record<string, any>;
|
|
66
|
-
|
|
67
|
-
if (foundUser && foundUser.platform) {
|
|
68
|
-
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
69
|
-
const confirmationToken = await jwtService.issue(
|
|
70
|
-
{ userId: user.id, platformId: foundUser.platform.id },
|
|
71
|
-
{ expiresIn: '1d' }
|
|
72
|
-
);
|
|
73
|
-
await strapi.entityService.update(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
74
|
-
data: { confirmationToken: confirmationToken } as Record<string, any>
|
|
75
|
-
});
|
|
46
|
+
try {
|
|
47
|
+
const foundUser = (await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
48
|
+
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
49
|
+
})) as Record<string, any>;
|
|
76
50
|
|
|
77
|
-
|
|
51
|
+
if (!foundUser?.platform?.platformEmails?.adminEmail?.fromEmail) {
|
|
52
|
+
throw new Error('Account Admin Mail is not configured');
|
|
53
|
+
}
|
|
78
54
|
|
|
79
55
|
await this.sendMail({
|
|
80
|
-
from: foundUser
|
|
81
|
-
to: foundUser
|
|
82
|
-
nameSender:
|
|
83
|
-
subject: foundUser
|
|
84
|
-
text: foundUser
|
|
56
|
+
from: foundUser?.platform?.platformEmails?.adminEmail?.fromEmail,
|
|
57
|
+
to: foundUser?.platform?.platformEmails?.adminEmail?.toEmail,
|
|
58
|
+
nameSender: foundUser?.platform.platformEmails.adminEmail.nameSender,
|
|
59
|
+
subject: foundUser?.platform?.platformEmails?.adminEmail?.subject,
|
|
60
|
+
text: foundUser?.platform?.platformEmails?.adminEmail?.message,
|
|
85
61
|
variables: {
|
|
86
|
-
firstName:
|
|
87
|
-
|
|
88
|
-
lastName: foundUser.lastName,
|
|
89
|
-
confirmEmailUrl
|
|
62
|
+
firstName: user.firstName,
|
|
63
|
+
lastName: user.lastName
|
|
90
64
|
}
|
|
91
65
|
});
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.error('Send Admin Mail Error:', e);
|
|
92
68
|
}
|
|
93
69
|
},
|
|
94
|
-
async
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
70
|
+
async sendConfirmationEmail(user) {
|
|
71
|
+
try {
|
|
72
|
+
const foundUser = (await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
73
|
+
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
74
|
+
})) as Record<string, any>;
|
|
75
|
+
|
|
76
|
+
if (foundUser && foundUser.platform) {
|
|
77
|
+
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
78
|
+
const confirmationToken = await jwtService.issue(
|
|
79
|
+
{ userId: user.id, platformId: foundUser.platform.id },
|
|
80
|
+
{ expiresIn: '1d' }
|
|
81
|
+
);
|
|
82
|
+
await strapi.entityService.update(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
83
|
+
data: { confirmationToken: confirmationToken } as Record<string, any>
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const confirmEmailUrl = `${strapi.config.server.url}/api/page-builder/activate/${confirmationToken}`;
|
|
87
|
+
|
|
88
|
+
if (!foundUser?.platform?.platformEmails?.accountCreatedMail?.fromEmail) {
|
|
89
|
+
throw new Error('Account Confirmation Mail is not configured');
|
|
90
|
+
}
|
|
107
91
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
92
|
+
await this.sendMail({
|
|
93
|
+
from: foundUser?.platform?.platformEmails?.accountCreatedMail?.fromEmail,
|
|
94
|
+
to: foundUser?.email,
|
|
95
|
+
nameSender: foundUser?.platform?.platformEmails?.accountCreatedMail?.nameSender,
|
|
96
|
+
subject: foundUser?.platform?.platformEmails?.accountCreatedMail?.subject,
|
|
97
|
+
text: foundUser?.platform?.platformEmails?.accountCreatedMail?.message,
|
|
98
|
+
variables: {
|
|
99
|
+
firstName: foundUser?.firstName,
|
|
100
|
+
lastName: foundUser?.lastName,
|
|
101
|
+
confirmEmailUrl
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
console.error('Send Confirmation Mail Error:', e);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
async sendForgotPasswordMail(user) {
|
|
110
|
+
try {
|
|
111
|
+
if (user && user.platform) {
|
|
112
|
+
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
113
|
+
|
|
114
|
+
const resetPasswordToken = await jwtService.issue(
|
|
115
|
+
{ userId: user.id, platformId: user.platform.id },
|
|
116
|
+
{ expiresIn: '1d' }
|
|
117
|
+
);
|
|
118
|
+
await strapi.entityService.update(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
119
|
+
data: { resetPasswordToken } as Record<string, any>
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (!user?.platform?.platformEmails?.resetPasswordMail?.fromEmail) {
|
|
123
|
+
throw new Error('Forgot Password Mail is not configured');
|
|
118
124
|
}
|
|
119
|
-
|
|
125
|
+
|
|
126
|
+
const resetPasswordUrl = getResetPasswordUrl(user, resetPasswordToken);
|
|
127
|
+
|
|
128
|
+
await this.sendMail({
|
|
129
|
+
from: user.platform.platformEmails.resetPasswordMail.fromEmail,
|
|
130
|
+
to: user.email,
|
|
131
|
+
nameSender: user.platform.platformEmails.resetPasswordMail.nameSender,
|
|
132
|
+
subject: user.platform.platformEmails.resetPasswordMail.subject,
|
|
133
|
+
text: user.platform.platformEmails.resetPasswordMail.message,
|
|
134
|
+
variables: {
|
|
135
|
+
firstName: user?.firstName,
|
|
136
|
+
lastName: user?.lastName,
|
|
137
|
+
resetPasswordUrl
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
} catch (e) {
|
|
142
|
+
console.error('Send Forgot Password Mail Error:', e);
|
|
120
143
|
}
|
|
121
144
|
}
|
|
122
145
|
};
|
|
@@ -127,15 +150,15 @@ const getResetPasswordUrl = (user?: Record<string, any>, resetPasswordToken?: st
|
|
|
127
150
|
}
|
|
128
151
|
|
|
129
152
|
if (
|
|
130
|
-
user
|
|
131
|
-
user
|
|
153
|
+
user?.platform?.platformEmails?.resetPasswordUrl &&
|
|
154
|
+
user?.platform?.platformEmails?.resetPasswordUrl.includes('{{resetPasswordToken}}')
|
|
132
155
|
) {
|
|
133
156
|
const replacedTokens = user.platform.platformEmails.resetPasswordUrl
|
|
134
|
-
.replace('{{domain}}', user
|
|
157
|
+
.replace('{{domain}}', user?.platform?.domain)
|
|
135
158
|
.replace('{{resetPasswordToken}}', resetPasswordToken);
|
|
136
159
|
|
|
137
160
|
return replacedTokens;
|
|
138
161
|
}
|
|
139
162
|
|
|
140
|
-
return `${user
|
|
163
|
+
return `${user?.platform?.domain}/wachtwoord-resetten/${resetPasswordToken}`;
|
|
141
164
|
};
|