@webbio/strapi-plugin-page-builder 0.9.7-platform → 0.9.8-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/README.md +30 -0
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +1 -1
- package/admin/src/components/PlatformFilteredSelectField/index.tsx +35 -2
- package/dist/package.json +9 -3
- package/dist/server/bootstrap.js +31 -1
- package/dist/server/controllers/index.js +3 -1
- package/dist/server/controllers/private-content.js +10 -0
- package/dist/server/graphql/page-by-path.js +19 -2
- package/dist/server/register.js +13 -0
- package/dist/server/routes/index.js +17 -0
- package/dist/server/schema/page-end.json +8 -0
- package/dist/server/services/builder.js +86 -0
- package/dist/server/services/constants/customUserConstants.js +16 -0
- package/dist/server/services/custom-user.js +161 -0
- package/dist/server/services/email.js +127 -0
- package/dist/server/services/index.js +5 -1
- package/dist/server/services/private-content/auth.js +0 -0
- package/dist/server/services/private-content/components/admin-email.json +22 -0
- package/dist/server/services/private-content/components/email.json +22 -0
- package/dist/server/services/private-content/components/platform-email.json +30 -0
- package/dist/server/services/private-content/constants/index.js +16 -0
- package/dist/server/services/private-content/email.js +3 -0
- package/dist/server/services/private-content/graphql/index.js +77 -0
- package/dist/server/services/private-content/graphql/resolvers/findOnePage.js +40 -0
- package/dist/server/services/private-content/graphql/resolvers/findPage.js +43 -0
- package/dist/server/services/private-content/graphql/resolvers/forgot-password.js +26 -0
- package/dist/server/services/private-content/graphql/resolvers/login.js +44 -0
- package/dist/server/services/private-content/graphql/resolvers/register.js +60 -0
- package/dist/server/services/private-content/graphql/resolvers/reset-password.js +41 -0
- package/dist/server/services/private-content/graphql/types/index.js +91 -0
- package/dist/server/services/private-content/graphql.js +128 -0
- package/dist/server/services/private-content/hash.js +0 -0
- package/dist/server/services/private-content/index.js +81 -0
- package/dist/server/services/private-content/mail-template/txtMail.email.template.text.js +12 -0
- package/dist/server/services/private-content/mail-template/txtMail.interface.js +2 -0
- package/dist/server/services/private-content/page.js +17 -0
- package/dist/server/services/private-content/platform.js +17 -0
- package/dist/server/services/private-content/schemas/index.js +30 -0
- package/dist/server/services/private-content/user.js +159 -0
- package/dist/server/utils/strapi.js +9 -1
- package/dist/shared/utils/constants.js +3 -1
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +9 -3
- package/server/bootstrap.ts +39 -1
- package/server/controllers/index.ts +3 -1
- package/server/controllers/private-content.ts +10 -0
- package/server/graphql/page-by-path.ts +24 -2
- package/server/register.ts +14 -0
- package/server/routes/index.ts +17 -0
- package/server/schema/page-end.json +9 -1
- package/server/services/builder.ts +83 -1
- package/server/services/email.ts +122 -0
- package/server/services/index.ts +5 -1
- package/server/services/private-content/components/admin-email.json +23 -0
- package/server/services/private-content/components/email.json +23 -0
- package/server/services/private-content/components/platform-email.json +30 -0
- package/server/services/private-content/constants/index.ts +13 -0
- package/server/services/private-content/graphql/index.ts +88 -0
- package/server/services/private-content/graphql/resolvers/findOnePage.ts +40 -0
- package/server/services/private-content/graphql/resolvers/findPage.ts +45 -0
- package/server/services/private-content/graphql/resolvers/forgot-password.ts +26 -0
- package/server/services/private-content/graphql/resolvers/login.ts +51 -0
- package/server/services/private-content/graphql/resolvers/register.ts +68 -0
- package/server/services/private-content/graphql/resolvers/reset-password.ts +44 -0
- package/server/services/private-content/graphql/types/index.ts +98 -0
- package/server/services/private-content/index.ts +84 -0
- package/server/services/private-content/mail-template/txtMail.email.template.text.ts +7 -0
- package/server/services/private-content/mail-template/txtMail.interface.ts +7 -0
- package/server/services/private-content/page.ts +14 -0
- package/server/services/private-content/platform.ts +14 -0
- package/server/services/private-content/schemas/index.ts +28 -0
- package/server/services/private-content/user.ts +187 -0
- package/server/utils/strapi.ts +5 -0
- package/shared/utils/constants.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webbio/strapi-plugin-page-builder",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8-authentication",
|
|
4
4
|
"description": "This is the description of the plugin.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"develop": "tsc -p tsconfig.server.json -w",
|
|
@@ -20,14 +20,20 @@
|
|
|
20
20
|
"url": "https://github.com/webbio/strapi-plugin-page-builder.git"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@aws-sdk/client-ses": "^3.485.0",
|
|
23
24
|
"@mantine/hooks": "^7.2.2",
|
|
24
25
|
"@strapi/design-system": "^1.11.0",
|
|
25
26
|
"@strapi/helper-plugin": "^4.15.0",
|
|
26
27
|
"@strapi/icons": "^1.11.0",
|
|
28
|
+
"@strapi/provider-email-amazon-ses": "^4.16.2",
|
|
27
29
|
"@strapi/typescript-utils": "^4.15.0",
|
|
28
30
|
"@strapi/utils": "^4.15.0",
|
|
31
|
+
"add": "^2.0.6",
|
|
32
|
+
"aws-sdk": "^2.1528.0",
|
|
33
|
+
"handlebars": "^4.7.8",
|
|
29
34
|
"react-select": "^5.7.4",
|
|
30
|
-
"slugify": "^1.6.6"
|
|
35
|
+
"slugify": "^1.6.6",
|
|
36
|
+
"yarn": "^1.22.21"
|
|
31
37
|
},
|
|
32
38
|
"devDependencies": {
|
|
33
39
|
"@types/react": "^18.2.21",
|
|
@@ -42,7 +48,7 @@
|
|
|
42
48
|
},
|
|
43
49
|
"peerDependencies": {
|
|
44
50
|
"@strapi/strapi": "^4.15.0",
|
|
45
|
-
"@webbio/strapi-plugin-slug": "^3.0.
|
|
51
|
+
"@webbio/strapi-plugin-slug": "^3.0.1",
|
|
46
52
|
"react": "^17.0.0 || ^18.0.0",
|
|
47
53
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
48
54
|
"react-router-dom": "^5.3.4",
|
package/server/bootstrap.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Common, Strapi } from '@strapi/strapi';
|
|
2
2
|
import { errors } from '@strapi/utils';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
PAGE_BUILDER_EMAIL_PLUGIN,
|
|
5
|
+
PAGE_TYPE_UID,
|
|
6
|
+
PAGE_UID,
|
|
7
|
+
PLATFORM_UID,
|
|
8
|
+
USER_PERMISSION_USER_PLUGIN
|
|
9
|
+
} from '../shared/utils/constants';
|
|
4
10
|
import permissions from './bootstrap/permissions';
|
|
5
11
|
import collectionTypeLifecycles from './bootstrap/collection-type-lifecycles';
|
|
6
12
|
|
|
@@ -20,6 +26,38 @@ export default async ({ strapi }: { strapi: Strapi }) => {
|
|
|
20
26
|
return data;
|
|
21
27
|
};
|
|
22
28
|
|
|
29
|
+
const plugin = strapi.plugin('users-permissions');
|
|
30
|
+
|
|
31
|
+
plugin.services.user.fetchAuthenticatedUser = async (id: any) => {
|
|
32
|
+
return strapi.query('plugin::users-permissions.user').findOne({ where: { id }, populate: ['role', 'platform'] });
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
strapi.db?.lifecycles.subscribe({
|
|
36
|
+
models: [USER_PERMISSION_USER_PLUGIN],
|
|
37
|
+
async beforeUpdate(event) {
|
|
38
|
+
if (event.params.data.id) {
|
|
39
|
+
const userToUpdate = await strapi.entityService?.findOne(USER_PERMISSION_USER_PLUGIN, event.params.data.id, {
|
|
40
|
+
populate: { platform: { populate: { platformMails: { populate: '*' } } } }
|
|
41
|
+
});
|
|
42
|
+
if (userToUpdate) {
|
|
43
|
+
if (event.params.data.activateUser && event.params.data.confirmed && !userToUpdate.confirmMailSend) {
|
|
44
|
+
await strapi.service(PAGE_BUILDER_EMAIL_PLUGIN).sendMail({
|
|
45
|
+
// @ts-ignore strapi typings
|
|
46
|
+
from: userToUpdate.platform.platformMails.accountAcceptedMail.fromEmail,
|
|
47
|
+
to: event.params.data.email,
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
subject: userToUpdate.platform.platformMails.accountAcceptedMail.subject,
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
text: userToUpdate.platform.platformMails.accountAcceptedMail.message,
|
|
52
|
+
firstName: event.params.data.firstName,
|
|
53
|
+
lastName: event.params.data.lastName
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
23
61
|
strapi.db?.lifecycles.subscribe({
|
|
24
62
|
// @ts-ignore
|
|
25
63
|
models: [PAGE_UID],
|
|
@@ -3,11 +3,13 @@ import pageType from './page-type';
|
|
|
3
3
|
import collectionTypes from './collection-types';
|
|
4
4
|
import template from './template';
|
|
5
5
|
import platform from './platform';
|
|
6
|
+
import privateContent from './private-content';
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
page,
|
|
9
10
|
'page-type': pageType,
|
|
10
11
|
'collection-types': collectionTypes,
|
|
11
12
|
template,
|
|
12
|
-
platform
|
|
13
|
+
platform,
|
|
14
|
+
'private-content': privateContent
|
|
13
15
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Strapi } from '@strapi/strapi';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
activateUser(ctx) {
|
|
5
|
+
return (strapi as Strapi).service('plugin::page-builder.private-content').activateUser(ctx.params.token);
|
|
6
|
+
},
|
|
7
|
+
removeInactiveUsers(ctx) {
|
|
8
|
+
return (strapi as Strapi).service('plugin::page-builder.private-content').removeInactiveUsers();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
@@ -2,6 +2,8 @@ import { Strapi } from '@strapi/strapi';
|
|
|
2
2
|
|
|
3
3
|
import { PAGE_UID } from '../../shared/utils/constants';
|
|
4
4
|
|
|
5
|
+
import { ForbiddenError as ApolloForbiddenError } from 'apollo-server-koa';
|
|
6
|
+
|
|
5
7
|
const getPageByPath = (strapi: Strapi) => {
|
|
6
8
|
const typeDefs = () => {
|
|
7
9
|
return `
|
|
@@ -34,7 +36,6 @@ const getPageByPath = (strapi: Strapi) => {
|
|
|
34
36
|
};
|
|
35
37
|
|
|
36
38
|
const { toEntityResponse } = strapi.plugin('graphql').service('format').returnTypes;
|
|
37
|
-
|
|
38
39
|
const getPage = async () => {
|
|
39
40
|
const transformedArgs = transformArgs(filteredArgs, {
|
|
40
41
|
contentType: strapi.contentTypes[PAGE_UID],
|
|
@@ -75,7 +76,28 @@ const getPageByPath = (strapi: Strapi) => {
|
|
|
75
76
|
const results: Record<string, any> = await getPage();
|
|
76
77
|
|
|
77
78
|
if (Object.values(results)?.filter(Boolean).length > 0) {
|
|
78
|
-
|
|
79
|
+
if (!results?.platform?.isPrivate && !results.isPrivate) {
|
|
80
|
+
return results;
|
|
81
|
+
}
|
|
82
|
+
if (
|
|
83
|
+
(results?.platform?.isPrivate === true && ctx.koaContext.req.headers.authorization) ||
|
|
84
|
+
(results?.isPrivate === true && ctx.koaContext.req.headers.authorization)
|
|
85
|
+
) {
|
|
86
|
+
const auth = ctx.koaContext.req.headers.authorization;
|
|
87
|
+
const token = auth.split(' ');
|
|
88
|
+
|
|
89
|
+
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
90
|
+
const decodedToken = await jwtService.verify(token[1]);
|
|
91
|
+
if (decodedToken) {
|
|
92
|
+
const user = ctx.state.user;
|
|
93
|
+
|
|
94
|
+
if (user?.platform?.id === results?.platform?.id) {
|
|
95
|
+
return results;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return new ApolloForbiddenError('Forbidden access');
|
|
79
101
|
} else {
|
|
80
102
|
throw new Error(ctx.koaContext.response.message);
|
|
81
103
|
}
|
package/server/register.ts
CHANGED
|
@@ -16,6 +16,20 @@ export default async ({ strapi }: { strapi: Strapi }) => {
|
|
|
16
16
|
extensionService.use(pageType);
|
|
17
17
|
extensionService.use(getPageByPath(strapi));
|
|
18
18
|
extensionService.use(getPageInfoFromUID(strapi));
|
|
19
|
+
extensionService.shadowCRUD('api::page.page').disableActions(['find', 'findOne']);
|
|
20
|
+
|
|
21
|
+
// const contentTypeName = await strapi.contentType('plugin::users-permissions.user');
|
|
22
|
+
// contentTypeName.attributes = {
|
|
23
|
+
// // Spread previous defined attributes
|
|
24
|
+
// ...contentTypeName.attributes,
|
|
25
|
+
// // Add new, or override attributes
|
|
26
|
+
// platform: {
|
|
27
|
+
// type: 'relation',
|
|
28
|
+
// relation: 'oneToOne',
|
|
29
|
+
// target: 'api::platform.platform'
|
|
30
|
+
// }
|
|
31
|
+
// };
|
|
19
32
|
|
|
20
33
|
await strapi.services?.['plugin::page-builder.builder']?.buildContentTypes();
|
|
34
|
+
await strapi.service('plugin::page-builder.private-content').enablePrivateContent();
|
|
21
35
|
};
|
package/server/routes/index.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
const routes = {
|
|
2
|
+
'private-content': {
|
|
3
|
+
type: 'content-api',
|
|
4
|
+
prefix: undefined,
|
|
5
|
+
routes: [
|
|
6
|
+
{
|
|
7
|
+
method: 'POST',
|
|
8
|
+
path: '/activate/:token',
|
|
9
|
+
handler: 'private-content.activateUser',
|
|
10
|
+
config: { policies: [], auth: false }
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
method: 'POST',
|
|
14
|
+
path: '/removeInactiveUsers',
|
|
15
|
+
handler: 'private-content.removeInactiveUsers'
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
},
|
|
2
19
|
'page-type': {
|
|
3
20
|
type: 'admin',
|
|
4
21
|
prefix: undefined,
|
|
@@ -11,10 +11,16 @@ import pageTypeEnd from '../schema/page-type-end.json';
|
|
|
11
11
|
import templateStart from '../schema/template-start.json';
|
|
12
12
|
import templateEnd from '../schema/template-end.json';
|
|
13
13
|
import platformStart from '../schema/platform-start.json';
|
|
14
|
+
import email from './private-content/components/email.json';
|
|
15
|
+
import platformEmail from './private-content/components/platform-email.json';
|
|
16
|
+
import adminEmail from './private-content/components/admin-email.json';
|
|
14
17
|
|
|
15
18
|
const UIDS: Common.UID.ContentType[] = [TEMPLATE_UID, PAGE_TYPE_UID, PLATFORM_UID, PAGE_UID];
|
|
16
19
|
|
|
17
20
|
export default {
|
|
21
|
+
async buildComponents() {
|
|
22
|
+
await this.createEmailComponents();
|
|
23
|
+
},
|
|
18
24
|
async buildContentTypes() {
|
|
19
25
|
this.listenToCreatedContentTypes();
|
|
20
26
|
|
|
@@ -29,7 +35,83 @@ export default {
|
|
|
29
35
|
}
|
|
30
36
|
});
|
|
31
37
|
},
|
|
32
|
-
|
|
38
|
+
async createEmailComponents() {
|
|
39
|
+
const foundEmailComponent = strapi.components['internal.email'];
|
|
40
|
+
const foundAdminEmail = strapi.components['internal.admin-email'];
|
|
41
|
+
const foundPlatformEmail = strapi.components['internal.platform-email'];
|
|
42
|
+
|
|
43
|
+
if (!foundAdminEmail && !foundEmailComponent && !foundPlatformEmail) {
|
|
44
|
+
try {
|
|
45
|
+
const res = await strapi.plugin('content-type-builder').services.components.createComponent({
|
|
46
|
+
component: {
|
|
47
|
+
category: 'internal',
|
|
48
|
+
displayName: platformEmail.info.displayName,
|
|
49
|
+
attributes: platformEmail.attributes
|
|
50
|
+
},
|
|
51
|
+
components: [
|
|
52
|
+
{
|
|
53
|
+
tmpUID: 'internal.email',
|
|
54
|
+
category: 'internal',
|
|
55
|
+
displayName: email.info.displayName,
|
|
56
|
+
attributes: email.attributes
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
tmpUID: 'internal.admin-email',
|
|
60
|
+
category: 'internal',
|
|
61
|
+
displayName: adminEmail.info.displayName,
|
|
62
|
+
attributes: adminEmail.attributes
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
return res;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.log(error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
async createEmailComponent() {
|
|
73
|
+
try {
|
|
74
|
+
const res = await strapi.plugin('content-type-builder').services.components.createComponent({
|
|
75
|
+
component: {
|
|
76
|
+
category: 'internal',
|
|
77
|
+
displayName: email.info.displayName,
|
|
78
|
+
attributes: email.attributes
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return res;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.log(error);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
async createPlatformEmail() {
|
|
87
|
+
try {
|
|
88
|
+
const res = await strapi.plugin('content-type-builder').services.components.createComponent({
|
|
89
|
+
component: {
|
|
90
|
+
category: 'internal',
|
|
91
|
+
displayName: platformEmail.info.displayName,
|
|
92
|
+
attributes: platformEmail.attributes
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return res;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.log(error);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
async createAdminEmail() {
|
|
101
|
+
try {
|
|
102
|
+
const res = await strapi.plugin('content-type-builder').services.components.createComponent({
|
|
103
|
+
component: {
|
|
104
|
+
category: 'internal',
|
|
105
|
+
displayName: adminEmail.info.displayName,
|
|
106
|
+
attributes: adminEmail.attributes
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
console.log(res);
|
|
110
|
+
return res;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.log(error);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
33
115
|
async createContentTypes() {
|
|
34
116
|
const newContentTypes = UIDS.filter((c) => !Boolean(strapi.contentType(c)))
|
|
35
117
|
.map((c) => this.getContentType(c)?.create)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as AWS from '@aws-sdk/client-ses';
|
|
2
|
+
import { txtEmail } from './private-content/mail-template/txtMail.email.template.text';
|
|
3
|
+
import { USER_PERMISSION_USER_PLUGIN } from '../../shared/utils/constants';
|
|
4
|
+
|
|
5
|
+
interface SendOptions {
|
|
6
|
+
from: string;
|
|
7
|
+
to: string;
|
|
8
|
+
subject: string;
|
|
9
|
+
text: string;
|
|
10
|
+
firstName: string;
|
|
11
|
+
lastName: string;
|
|
12
|
+
confirmationUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
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
|
+
});
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const client = new AWS.SES();
|
|
28
|
+
await client.sendEmail({
|
|
29
|
+
Source: from,
|
|
30
|
+
Destination: {
|
|
31
|
+
ToAddresses: [to]
|
|
32
|
+
},
|
|
33
|
+
Message: {
|
|
34
|
+
Subject: { Data: subject },
|
|
35
|
+
Body: {
|
|
36
|
+
Text: { Data: emailData }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(error);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
async sendAdminMail(user) {
|
|
45
|
+
const foundUser = await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
46
|
+
populate: { platform: { populate: { platformMails: { populate: '*' } } } }
|
|
47
|
+
});
|
|
48
|
+
await this.sendMail({
|
|
49
|
+
// @ts-ignore we all love strapi typings
|
|
50
|
+
from: foundUser.platform.platformMails.adminEmail.fromEmail,
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
to: foundUser.platform.platformMails.adminEmail.toMail,
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
subject: foundUser.platform.platformMails.adminEmail.subject,
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
text: foundUser.platform.platformMails.adminEmail.message,
|
|
57
|
+
firstName: user.firstName,
|
|
58
|
+
lastName: user.lastName
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
async sendConfirmationEmail(user) {
|
|
62
|
+
const foundUser = await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
63
|
+
populate: { platform: { populate: { platformMails: { populate: '*' } } } }
|
|
64
|
+
});
|
|
65
|
+
if (foundUser && foundUser.platform) {
|
|
66
|
+
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
67
|
+
const confirmationToken = await jwtService.issue(
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
{ userId: user.id, platformId: foundUser.platform.id },
|
|
70
|
+
{ expiresIn: '1d' }
|
|
71
|
+
);
|
|
72
|
+
await strapi.entityService.update(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
data: { confirmationToken: confirmationToken }
|
|
75
|
+
});
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
const activateUrl = `${foundUser.platform.domain}/api/page-builder/activate/${confirmationToken}`;
|
|
78
|
+
|
|
79
|
+
await this.sendMail({
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
from: foundUser.platform.platformMails.accountCreatedMail.fromEmail,
|
|
82
|
+
to: user.email,
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
subject: foundUser.platform.platformMails.accountCreatedMail.subject,
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
text: foundUser.platform.platformMails.accountCreatedMail.message,
|
|
87
|
+
firstName: user.firstName,
|
|
88
|
+
lastName: user.lastName,
|
|
89
|
+
confirmationUrl: activateUrl
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
async sendForgotPasswordMail(user) {
|
|
94
|
+
if (user && user.platform) {
|
|
95
|
+
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
96
|
+
|
|
97
|
+
const resetPasswordToken = await jwtService.issue(
|
|
98
|
+
{ userId: user.id, platformId: user.platform.id },
|
|
99
|
+
{ expiresIn: '1d' }
|
|
100
|
+
);
|
|
101
|
+
await strapi.entityService.update(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
data: { resetPasswordToken }
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const activateUrl = `${user.platform.domain}/api/page-builder/reset/${resetPasswordToken}`;
|
|
107
|
+
|
|
108
|
+
await this.sendMail({
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
from: user.platform.platformMails.resetPasswordMail.fromEmail,
|
|
111
|
+
to: user.email,
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
subject: user.platform.platformMails.resetPasswordMail.subject,
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
text: user.platform.platformMails.resetPasswordMail.message,
|
|
116
|
+
firstName: user.firstName,
|
|
117
|
+
lastName: user.lastName,
|
|
118
|
+
confirmationUrl: activateUrl
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
package/server/services/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ import pageType from './page-type';
|
|
|
4
4
|
import collectionTypes from './collection-types';
|
|
5
5
|
import template from './template';
|
|
6
6
|
import platform from './platform';
|
|
7
|
+
import email from './email';
|
|
8
|
+
import privateContent from './private-content';
|
|
7
9
|
|
|
8
10
|
export default {
|
|
9
11
|
page,
|
|
@@ -11,5 +13,7 @@ export default {
|
|
|
11
13
|
'page-type': pageType,
|
|
12
14
|
'collection-types': collectionTypes,
|
|
13
15
|
template,
|
|
14
|
-
platform
|
|
16
|
+
platform,
|
|
17
|
+
email,
|
|
18
|
+
'private-content': privateContent
|
|
15
19
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"collectionName": "components_internal_admin_emails",
|
|
3
|
+
"info": {
|
|
4
|
+
"displayName": "AdminEmail",
|
|
5
|
+
"description": ""
|
|
6
|
+
},
|
|
7
|
+
"options": {},
|
|
8
|
+
"attributes": {
|
|
9
|
+
"toMail": {
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"fromEmail": {
|
|
13
|
+
"type": "string"
|
|
14
|
+
},
|
|
15
|
+
"subject": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"message": {
|
|
19
|
+
"type": "text"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"collectionName": "components_internal_emails",
|
|
3
|
+
"info": {
|
|
4
|
+
"displayName": "email",
|
|
5
|
+
"description": ""
|
|
6
|
+
},
|
|
7
|
+
"options": {},
|
|
8
|
+
"attributes": {
|
|
9
|
+
"nameSender": {
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"fromEmail": {
|
|
13
|
+
"type": "string"
|
|
14
|
+
},
|
|
15
|
+
"subject": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"message": {
|
|
19
|
+
"type": "text"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"collectionName": "components_internal_platform_emails",
|
|
3
|
+
"info": {
|
|
4
|
+
"displayName": "PlatformEmail"
|
|
5
|
+
},
|
|
6
|
+
"options": {},
|
|
7
|
+
"attributes": {
|
|
8
|
+
"resetPasswordMail": {
|
|
9
|
+
"type": "component",
|
|
10
|
+
"repeatable": false,
|
|
11
|
+
"component": "internal.email"
|
|
12
|
+
},
|
|
13
|
+
"accountCreatedMail": {
|
|
14
|
+
"type": "component",
|
|
15
|
+
"repeatable": false,
|
|
16
|
+
"component": "internal.email"
|
|
17
|
+
},
|
|
18
|
+
"accountAcceptedMail": {
|
|
19
|
+
"type": "component",
|
|
20
|
+
"repeatable": false,
|
|
21
|
+
"component": "internal.email"
|
|
22
|
+
},
|
|
23
|
+
"adminEmail": {
|
|
24
|
+
"displayName": "AdminEmail",
|
|
25
|
+
"type": "component",
|
|
26
|
+
"repeatable": false,
|
|
27
|
+
"component": "internal.admin-email"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { contentTypes as contentTypesUtils } from '@strapi/utils';
|
|
2
|
+
export const { UPDATED_BY_ATTRIBUTE, CREATED_BY_ATTRIBUTE } = contentTypesUtils.constants;
|
|
3
|
+
|
|
4
|
+
export const USER_MODEL = 'plugin::users-permissions.user';
|
|
5
|
+
export const USER_CONTENT_MANAGER = 'plugin::users-permissions.contentmanageruser';
|
|
6
|
+
export const USER_ROLE = 'plugin::users-permissions.role';
|
|
7
|
+
export const CONTENT_ENTITY_MANAGER = 'plugin::content-manager.entity-manager';
|
|
8
|
+
export const ACTIONS = {
|
|
9
|
+
read: 'plugin::content-manager.explorer.read',
|
|
10
|
+
create: 'plugin::content-manager.explorer.create',
|
|
11
|
+
edit: 'plugin::content-manager.explorer.update',
|
|
12
|
+
delete: 'plugin::content-manager.explorer.delete'
|
|
13
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ForgotPasswordInput,
|
|
3
|
+
ForgotPasswordResponse,
|
|
4
|
+
LoginInput,
|
|
5
|
+
LoginResponse,
|
|
6
|
+
Mutations,
|
|
7
|
+
Queries,
|
|
8
|
+
RegisterInput,
|
|
9
|
+
RegisterResponse,
|
|
10
|
+
ResetPasswordInput,
|
|
11
|
+
ResetPasswordResponse,
|
|
12
|
+
User
|
|
13
|
+
} from './types';
|
|
14
|
+
import { platformRegister } from './resolvers/register';
|
|
15
|
+
import { platformLogin } from './resolvers/login';
|
|
16
|
+
import { platformForgotPassword } from './resolvers/forgot-password';
|
|
17
|
+
import { platformResetPassword } from './resolvers/reset-password';
|
|
18
|
+
import { page } from './resolvers/findOnePage';
|
|
19
|
+
import { pages } from './resolvers/findPage';
|
|
20
|
+
|
|
21
|
+
export const extendGraphQL = () => {
|
|
22
|
+
const extensionService = strapi.plugin('graphql').service('extension');
|
|
23
|
+
|
|
24
|
+
const extension = () => ({
|
|
25
|
+
typeDefs: `
|
|
26
|
+
${RegisterInput}
|
|
27
|
+
|
|
28
|
+
${LoginInput}
|
|
29
|
+
|
|
30
|
+
${RegisterResponse}
|
|
31
|
+
|
|
32
|
+
${LoginResponse}
|
|
33
|
+
|
|
34
|
+
${User}
|
|
35
|
+
|
|
36
|
+
${Mutations}
|
|
37
|
+
|
|
38
|
+
${ForgotPasswordInput}
|
|
39
|
+
|
|
40
|
+
${ForgotPasswordResponse}
|
|
41
|
+
|
|
42
|
+
${ResetPasswordInput}
|
|
43
|
+
|
|
44
|
+
${ResetPasswordResponse}
|
|
45
|
+
|
|
46
|
+
${ResetPasswordInput}
|
|
47
|
+
|
|
48
|
+
${ResetPasswordResponse}
|
|
49
|
+
|
|
50
|
+
${Queries}
|
|
51
|
+
|
|
52
|
+
`,
|
|
53
|
+
resolvers: {
|
|
54
|
+
Query: {
|
|
55
|
+
page,
|
|
56
|
+
pages
|
|
57
|
+
},
|
|
58
|
+
Mutation: {
|
|
59
|
+
platformLogin,
|
|
60
|
+
platformRegister,
|
|
61
|
+
platformForgotPassword,
|
|
62
|
+
platformResetPassword
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
resolversConfig: {
|
|
66
|
+
'Mutation.platformLogin': {
|
|
67
|
+
auth: false
|
|
68
|
+
},
|
|
69
|
+
'Mutation.platformRegister': {
|
|
70
|
+
auth: false
|
|
71
|
+
},
|
|
72
|
+
'Mutation.platformForgotPassword': {
|
|
73
|
+
auth: false
|
|
74
|
+
},
|
|
75
|
+
'Mutation.platformResetPassword': {
|
|
76
|
+
auth: false
|
|
77
|
+
},
|
|
78
|
+
'Query.page': {
|
|
79
|
+
auth: false
|
|
80
|
+
},
|
|
81
|
+
'Query.pages': {
|
|
82
|
+
auth: false
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
extensionService.use(extension);
|
|
88
|
+
};
|