@webbio/strapi-plugin-page-builder 0.3.4-platform → 0.3.5-legacy
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 +21 -6
- package/admin/src/api/collection-type.ts +1 -7
- package/admin/src/api/page-type.ts +4 -5
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +12 -15
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +28 -10
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +32 -61
- package/admin/src/components/EditView/Details/index.tsx +1 -1
- package/admin/src/components/EditView/PageSettings/index.tsx +6 -74
- package/admin/src/components/PageTypeFilter/index.tsx +17 -0
- package/admin/src/components/PageTypeFilter/page-type-filter.tsx +130 -0
- package/admin/src/index.tsx +2 -2
- package/admin/src/utils/sanitizeModules.ts +92 -9
- package/dist/package.json +12 -10
- package/dist/server/bootstrap/permissions.js +10 -68
- package/dist/server/bootstrap.js +24 -40
- package/dist/server/content-types/user-categories/schema.json +18 -0
- package/dist/server/content-types/user-category/schema.json +23 -0
- package/dist/server/controllers/index.js +1 -3
- package/dist/server/controllers/platform.js +5 -5
- package/dist/server/controllers/private-content.js +18 -0
- package/dist/server/controllers/sitemap.js +29 -0
- package/dist/server/controllers/user-category.js +4 -0
- package/dist/server/graphql/page-by-path.js +113 -0
- package/dist/server/graphql/page-by-slug.js +37 -44
- package/dist/server/graphql/pages-by-uid.js +7 -9
- package/dist/server/policies/isAuthorizedPage.js +11 -0
- package/dist/server/routes/index.js +0 -21
- package/dist/server/routes/user-category.js +4 -0
- package/dist/server/schema/page-end.json +0 -5
- package/dist/server/schema/platform-start.json +0 -10
- package/dist/server/schema/template-end.json +40 -0
- package/dist/server/services/builder.js +5 -15
- package/dist/server/services/email.js +160 -0
- package/dist/server/services/index.js +1 -3
- package/dist/server/services/platform.js +6 -11
- 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 +33 -0
- package/dist/server/services/private-content/constants/index.js +16 -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 +44 -0
- package/dist/server/services/private-content/graphql/resolvers/forgot-password.js +29 -0
- package/dist/server/services/private-content/graphql/resolvers/login.js +49 -0
- package/dist/server/services/private-content/graphql/resolvers/register.js +68 -0
- package/dist/server/services/private-content/graphql/resolvers/reset-password.js +41 -0
- package/dist/server/services/private-content/graphql/types/index.js +89 -0
- package/dist/server/services/private-content/index.js +94 -0
- package/dist/server/services/private-content/mail-template/txtMail.email.template.text.js +12 -0
- package/dist/server/services/private-content/page.js +22 -0
- package/dist/server/services/private-content/platform.js +22 -0
- package/dist/server/services/private-content/schemas/index.js +30 -0
- package/dist/server/services/private-content/user.js +170 -0
- package/dist/server/services/sitemap.js +78 -0
- package/dist/server/services/template.js +1 -2
- package/dist/server/services/user-category.js +4 -0
- package/dist/server/utils/strapi.js +1 -4
- package/dist/shared/utils/constants.js +1 -3
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +12 -10
- package/server/bootstrap/collection-type-lifecycles.ts +1 -1
- package/server/bootstrap/permissions.ts +10 -75
- package/server/bootstrap.ts +24 -43
- package/server/controllers/index.ts +1 -3
- package/server/graphql/page-by-slug.ts +43 -50
- package/server/graphql/pages-by-uid.ts +7 -9
- package/server/routes/index.ts +0 -21
- package/server/schema/page-end.json +0 -5
- package/server/services/builder.ts +6 -18
- package/server/services/index.ts +1 -3
- package/server/services/template.ts +1 -2
- package/server/utils/strapi.ts +1 -5
- package/shared/utils/constants.ts +0 -2
- package/admin/src/api/platform-page-types.ts +0 -40
- package/admin/src/api/platform.ts +0 -34
- package/admin/src/components/EditView/Platform/platform-select.tsx +0 -30
- package/admin/src/components/PageFilters/PageTypeFilter/index.tsx +0 -39
- package/admin/src/components/PageFilters/PlatformFilter/index.tsx +0 -28
- package/admin/src/components/PageFilters/filters.tsx +0 -180
- package/admin/src/components/PageFilters/index.tsx +0 -30
- package/server/controllers/platform.ts +0 -21
- package/server/schema/platform-start.json +0 -31
- package/server/services/platform.ts +0 -36
|
@@ -10,7 +10,7 @@ const getPageBySlug = (strapi) => {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
type Query {
|
|
13
|
-
getPageBySlug(path: String,
|
|
13
|
+
getPageBySlug(path: String, _locale: String, _publicationState: PublicationState): PageEntity
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
`;
|
|
@@ -22,52 +22,45 @@ const getPageBySlug = (strapi) => {
|
|
|
22
22
|
getPageBySlug: {
|
|
23
23
|
resolve: async (_parent, args, ctx) => {
|
|
24
24
|
var _a;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
if (!(entityResponse === null || entityResponse === void 0 ? void 0 : entityResponse.value) || Object.keys(entityResponse.value).length === 0) {
|
|
48
|
-
throw new Error(ctx.koaContext.response.message);
|
|
49
|
-
}
|
|
50
|
-
const collectionTypeDataFilter = (_c = (_b = entityResponse === null || entityResponse === void 0 ? void 0 : entityResponse.value) === null || _b === void 0 ? void 0 : _b.collectionTypeData) === null || _c === void 0 ? void 0 : _c.filter(Boolean);
|
|
51
|
-
const collectionType = collectionTypeDataFilter.length === 1 ? collectionTypeDataFilter === null || collectionTypeDataFilter === void 0 ? void 0 : collectionTypeDataFilter[0] : null;
|
|
52
|
-
const addedAttributes = {
|
|
53
|
-
collectionType: collectionType
|
|
54
|
-
};
|
|
55
|
-
const result = {
|
|
56
|
-
...entityResponse.value,
|
|
57
|
-
...addedAttributes
|
|
58
|
-
};
|
|
59
|
-
return result;
|
|
60
|
-
};
|
|
61
|
-
const results = await getPage();
|
|
62
|
-
if (((_a = Object.values(results)) === null || _a === void 0 ? void 0 : _a.filter(Boolean).length) > 0) {
|
|
63
|
-
return results;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
25
|
+
const filteredArgs = {
|
|
26
|
+
...(0, filter_underscore_arguments_1.filterUnderscoreArguments)(args)
|
|
27
|
+
};
|
|
28
|
+
const { toEntityResponse } = strapi.plugin('graphql').service('format').returnTypes;
|
|
29
|
+
const getPage = async () => {
|
|
30
|
+
var _a, _b, _c;
|
|
31
|
+
const transformedArgs = transformArgs(filteredArgs, {
|
|
32
|
+
contentType: strapi.contentTypes[constants_1.PAGE_UID],
|
|
33
|
+
usePagination: false
|
|
34
|
+
});
|
|
35
|
+
const results = await ((_a = strapi.entityService) === null || _a === void 0 ? void 0 : _a.findMany(constants_1.PAGE_UID, {
|
|
36
|
+
filters: transformedArgs,
|
|
37
|
+
locale: args._locale,
|
|
38
|
+
publicationState: args._publicationState,
|
|
39
|
+
populate: '*'
|
|
40
|
+
}));
|
|
41
|
+
const entityResponse = toEntityResponse((results === null || results === void 0 ? void 0 : results[0]) || {}, {
|
|
42
|
+
args: transformedArgs,
|
|
43
|
+
resourceUID: constants_1.PAGE_UID
|
|
44
|
+
});
|
|
45
|
+
if (!(entityResponse === null || entityResponse === void 0 ? void 0 : entityResponse.value) || Object.keys(entityResponse.value).length === 0) {
|
|
66
46
|
throw new Error(ctx.koaContext.response.message);
|
|
67
47
|
}
|
|
48
|
+
const collectionTypeDataFilter = (_c = (_b = entityResponse === null || entityResponse === void 0 ? void 0 : entityResponse.value) === null || _b === void 0 ? void 0 : _b.collectionTypeData) === null || _c === void 0 ? void 0 : _c.filter(Boolean);
|
|
49
|
+
const collectionType = collectionTypeDataFilter.length === 1 ? collectionTypeDataFilter === null || collectionTypeDataFilter === void 0 ? void 0 : collectionTypeDataFilter[0] : null;
|
|
50
|
+
const addedAttributes = {
|
|
51
|
+
collectionType: collectionType
|
|
52
|
+
};
|
|
53
|
+
const result = {
|
|
54
|
+
...entityResponse.value,
|
|
55
|
+
...addedAttributes
|
|
56
|
+
};
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
const results = await getPage();
|
|
60
|
+
if (((_a = Object.values(results)) === null || _a === void 0 ? void 0 : _a.filter(Boolean).length) > 0) {
|
|
61
|
+
return results;
|
|
68
62
|
}
|
|
69
|
-
|
|
70
|
-
console.log('Error in getPageBySlug:', error);
|
|
63
|
+
else {
|
|
71
64
|
throw new Error(ctx.koaContext.response.message);
|
|
72
65
|
}
|
|
73
66
|
}
|
|
@@ -14,16 +14,13 @@ const getPageInfoFromUID = (strapi) => {
|
|
|
14
14
|
pageSize: Int
|
|
15
15
|
}`;
|
|
16
16
|
const entityInfo = collectionTypes.map((collectionType) => {
|
|
17
|
-
return `
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
17
|
+
return `extend type ${collectionType.type}EntityResponseCollection {
|
|
18
|
+
metaInfo: MetaInfo
|
|
19
|
+
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`;
|
|
21
|
+
type Query {
|
|
22
|
+
get${collectionType.type}Pages(filters: ${collectionType.type}FiltersInput, pagination: PaginationArg, sort:[String], pageFilters: PageFiltersInput): ${collectionType.type}EntityResponseCollection
|
|
23
|
+
}`;
|
|
27
24
|
});
|
|
28
25
|
return `${metaInfo} ${entityInfo}`;
|
|
29
26
|
};
|
|
@@ -60,6 +57,7 @@ const getPageInfoFromUID = (strapi) => {
|
|
|
60
57
|
hasPage: { $eq: true },
|
|
61
58
|
page: { ...transformedpageArgs.filters }
|
|
62
59
|
},
|
|
60
|
+
sort: transformedArgs.sort,
|
|
63
61
|
start: start,
|
|
64
62
|
limit: limit
|
|
65
63
|
}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const isAuthorizedForPage = (policyContext, _config, { strapi }) => {
|
|
4
|
+
const pageToken = policyContext.http.request.headers['x-strapi-page-secret'];
|
|
5
|
+
const pageEnvToken = process.env.STRAPI_PAGE_SECRET;
|
|
6
|
+
if (pageToken && pageEnvToken && pageToken === pageEnvToken) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
};
|
|
11
|
+
exports.default = isAuthorizedForPage;
|
|
@@ -54,27 +54,6 @@ const routes = {
|
|
|
54
54
|
handler: 'template.findOneById'
|
|
55
55
|
}
|
|
56
56
|
]
|
|
57
|
-
},
|
|
58
|
-
platform: {
|
|
59
|
-
type: 'admin',
|
|
60
|
-
prefix: undefined,
|
|
61
|
-
routes: [
|
|
62
|
-
{
|
|
63
|
-
method: 'GET',
|
|
64
|
-
path: '/platform',
|
|
65
|
-
handler: 'platform.findAll'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
method: 'GET',
|
|
69
|
-
path: '/platform/:uid',
|
|
70
|
-
handler: 'platform.findOneByUid'
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
method: 'GET',
|
|
74
|
-
path: '/platform/:platform/page-types',
|
|
75
|
-
handler: 'platform.findPageTypesByPlatform'
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
57
|
}
|
|
79
58
|
};
|
|
80
59
|
exports.default = routes;
|
|
@@ -16,16 +16,6 @@
|
|
|
16
16
|
},
|
|
17
17
|
"domain": {
|
|
18
18
|
"type": "string"
|
|
19
|
-
},
|
|
20
|
-
"template": {
|
|
21
|
-
"type": "relation",
|
|
22
|
-
"relation": "oneToMany",
|
|
23
|
-
"target": "api::template.template"
|
|
24
|
-
},
|
|
25
|
-
"pageTypes": {
|
|
26
|
-
"type": "relation",
|
|
27
|
-
"relation": "oneToMany",
|
|
28
|
-
"target": "api::page-type.page-type"
|
|
29
19
|
}
|
|
30
20
|
}
|
|
31
21
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"draftAndPublish": false,
|
|
3
|
+
"displayName": "Templates",
|
|
4
|
+
"singularName": "template",
|
|
5
|
+
"pluralName": "templates",
|
|
6
|
+
"description": "",
|
|
7
|
+
"plugin": "page-builder",
|
|
8
|
+
"pluginOptions": {
|
|
9
|
+
"i18n": {
|
|
10
|
+
"localized": true
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"kind": "collectionType",
|
|
14
|
+
"collectionName": "templates",
|
|
15
|
+
"attributes": {
|
|
16
|
+
"title": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"required": true,
|
|
19
|
+
"pluginOptions": {
|
|
20
|
+
"i18n": {
|
|
21
|
+
"localized": true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"platform": {
|
|
26
|
+
"type": "relation",
|
|
27
|
+
"relation": "oneToOne",
|
|
28
|
+
"target": "api::platform.platform"
|
|
29
|
+
},
|
|
30
|
+
"modules": {
|
|
31
|
+
"type": "dynamiczone",
|
|
32
|
+
"components": [],
|
|
33
|
+
"pluginOptions": {
|
|
34
|
+
"i18n": {
|
|
35
|
+
"localized": true
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -12,8 +12,7 @@ const reload_strapi_on_load_1 = require("../utils/reload-strapi-on-load");
|
|
|
12
12
|
const page_type_start_json_1 = __importDefault(require("../schema/page-type-start.json"));
|
|
13
13
|
const page_type_end_json_1 = __importDefault(require("../schema/page-type-end.json"));
|
|
14
14
|
const template_start_json_1 = __importDefault(require("../schema/template-start.json"));
|
|
15
|
-
const
|
|
16
|
-
const UIDS = [constants_1.TEMPLATE_UID, constants_1.PAGE_TYPE_UID, constants_1.PLATFORM_UID, constants_1.PAGE_UID];
|
|
15
|
+
const UIDS = [constants_1.TEMPLATE_UID, constants_1.PAGE_TYPE_UID, constants_1.PAGE_UID];
|
|
17
16
|
exports.default = {
|
|
18
17
|
async buildContentTypes() {
|
|
19
18
|
this.listenToCreatedContentTypes();
|
|
@@ -73,35 +72,26 @@ exports.default = {
|
|
|
73
72
|
[constants_1.TEMPLATE_UID]: {
|
|
74
73
|
create: this.getTemplateContentType(),
|
|
75
74
|
update: this.getTemplateContentType()
|
|
76
|
-
},
|
|
77
|
-
[constants_1.PLATFORM_UID]: {
|
|
78
|
-
create: this.getPlatformContentType(),
|
|
79
|
-
update: this.getPlatformContentType()
|
|
80
75
|
}
|
|
81
76
|
};
|
|
82
77
|
return contentTypes === null || contentTypes === void 0 ? void 0 : contentTypes[uid];
|
|
83
78
|
},
|
|
84
79
|
getPageContentType(create) {
|
|
85
80
|
const page = create ? page_start_json_1.default : page_end_json_1.default;
|
|
86
|
-
const contentType = this.
|
|
81
|
+
const contentType = this.mergeCollectionTypeWithModules(page, constants_1.PAGE_UID);
|
|
87
82
|
return { uid: constants_1.PAGE_UID, contentType };
|
|
88
83
|
},
|
|
89
84
|
getPageTypeContentType(create) {
|
|
90
85
|
const pageType = create ? page_type_start_json_1.default : page_type_end_json_1.default;
|
|
91
|
-
const contentType = this.
|
|
86
|
+
const contentType = this.mergeCollectionTypeWithModules(pageType, constants_1.PAGE_TYPE_UID);
|
|
92
87
|
return { uid: constants_1.PAGE_TYPE_UID, contentType };
|
|
93
88
|
},
|
|
94
89
|
getTemplateContentType() {
|
|
95
90
|
const template = template_start_json_1.default;
|
|
96
|
-
const contentType = this.
|
|
91
|
+
const contentType = this.mergeCollectionTypeWithModules(template, constants_1.TEMPLATE_UID);
|
|
97
92
|
return { uid: constants_1.TEMPLATE_UID, contentType };
|
|
98
93
|
},
|
|
99
|
-
|
|
100
|
-
const platform = platform_start_json_1.default;
|
|
101
|
-
const contentType = this.mergeCollectionTypeWithOld(platform, constants_1.PLATFORM_UID);
|
|
102
|
-
return { uid: constants_1.PLATFORM_UID, contentType };
|
|
103
|
-
},
|
|
104
|
-
mergeCollectionTypeWithOld(collectionType, uid) {
|
|
94
|
+
mergeCollectionTypeWithModules(collectionType, uid) {
|
|
105
95
|
var _a, _b, _c, _d, _e, _f;
|
|
106
96
|
const { pluginOptions: oldPluginOptions, __schema__: oldSchema } = strapi.contentType(uid) || {};
|
|
107
97
|
const modulesFromConfig = ((_a = oldSchema === null || oldSchema === void 0 ? void 0 : oldSchema.attributes) === null || _a === void 0 ? void 0 : _a.modules) ? this.getConfigModuleComponents() : undefined;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const AWS = __importStar(require("@aws-sdk/client-ses"));
|
|
27
|
+
const txtMail_email_template_text_1 = require("./private-content/mail-template/txtMail.email.template.text");
|
|
28
|
+
const constants_1 = require("../../shared/utils/constants");
|
|
29
|
+
const utils_1 = require("@strapi/utils");
|
|
30
|
+
exports.default = {
|
|
31
|
+
async sendMail(options) {
|
|
32
|
+
const { from, to, subject, text, variables, nameSender } = options;
|
|
33
|
+
const emailData = (0, txtMail_email_template_text_1.txtEmail)(text, variables);
|
|
34
|
+
const Source = nameSender ? `${nameSender} <${from}>` : from;
|
|
35
|
+
try {
|
|
36
|
+
const client = new AWS.SES();
|
|
37
|
+
await client.sendEmail({
|
|
38
|
+
Source,
|
|
39
|
+
Destination: {
|
|
40
|
+
ToAddresses: [to]
|
|
41
|
+
},
|
|
42
|
+
Message: {
|
|
43
|
+
Subject: { Data: subject },
|
|
44
|
+
Body: {
|
|
45
|
+
Text: { Data: emailData }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error(error);
|
|
53
|
+
throw new utils_1.errors.ApplicationError('Failed to send email', error);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
async sendAdminMail(user) {
|
|
57
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
58
|
+
try {
|
|
59
|
+
const foundUser = (await strapi.entityService.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
60
|
+
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
61
|
+
}));
|
|
62
|
+
if (!((_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)) {
|
|
63
|
+
throw new Error('Account Admin Mail is not configured');
|
|
64
|
+
}
|
|
65
|
+
await this.sendMail({
|
|
66
|
+
from: (_f = (_e = (_d = foundUser === null || foundUser === void 0 ? void 0 : foundUser.platform) === null || _d === void 0 ? void 0 : _d.platformEmails) === null || _e === void 0 ? void 0 : _e.adminEmail) === null || _f === void 0 ? void 0 : _f.fromEmail,
|
|
67
|
+
to: (_j = (_h = (_g = foundUser === null || foundUser === void 0 ? void 0 : foundUser.platform) === null || _g === void 0 ? void 0 : _g.platformEmails) === null || _h === void 0 ? void 0 : _h.adminEmail) === null || _j === void 0 ? void 0 : _j.toEmail,
|
|
68
|
+
nameSender: foundUser === null || foundUser === void 0 ? void 0 : foundUser.platform.platformEmails.adminEmail.nameSender,
|
|
69
|
+
subject: (_m = (_l = (_k = foundUser === null || foundUser === void 0 ? void 0 : foundUser.platform) === null || _k === void 0 ? void 0 : _k.platformEmails) === null || _l === void 0 ? void 0 : _l.adminEmail) === null || _m === void 0 ? void 0 : _m.subject,
|
|
70
|
+
text: (_q = (_p = (_o = foundUser === null || foundUser === void 0 ? void 0 : foundUser.platform) === null || _o === void 0 ? void 0 : _o.platformEmails) === null || _p === void 0 ? void 0 : _p.adminEmail) === null || _q === void 0 ? void 0 : _q.message,
|
|
71
|
+
variables: {
|
|
72
|
+
firstName: user.firstName,
|
|
73
|
+
lastName: user.lastName
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
console.error('Send Admin Mail Error:', e);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
async sendConfirmationEmail(user) {
|
|
82
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
83
|
+
try {
|
|
84
|
+
const foundUser = (await strapi.entityService.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
85
|
+
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
86
|
+
}));
|
|
87
|
+
if (foundUser && foundUser.platform) {
|
|
88
|
+
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
89
|
+
const confirmationToken = await jwtService.issue({ userId: user.id, platformId: foundUser.platform.id }, { expiresIn: '1d' });
|
|
90
|
+
await strapi.entityService.update(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
91
|
+
data: { confirmationToken: confirmationToken }
|
|
92
|
+
});
|
|
93
|
+
const confirmEmailUrl = `${strapi.config.server.url}/api/page-builder/activate/${confirmationToken}`;
|
|
94
|
+
if (!((_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.accountCreatedMail) === null || _c === void 0 ? void 0 : _c.fromEmail)) {
|
|
95
|
+
throw new Error('Account Confirmation Mail is not configured');
|
|
96
|
+
}
|
|
97
|
+
await this.sendMail({
|
|
98
|
+
from: (_f = (_e = (_d = foundUser === null || foundUser === void 0 ? void 0 : foundUser.platform) === null || _d === void 0 ? void 0 : _d.platformEmails) === null || _e === void 0 ? void 0 : _e.accountCreatedMail) === null || _f === void 0 ? void 0 : _f.fromEmail,
|
|
99
|
+
to: foundUser === null || foundUser === void 0 ? void 0 : foundUser.email,
|
|
100
|
+
nameSender: (_j = (_h = (_g = foundUser === null || foundUser === void 0 ? void 0 : foundUser.platform) === null || _g === void 0 ? void 0 : _g.platformEmails) === null || _h === void 0 ? void 0 : _h.accountCreatedMail) === null || _j === void 0 ? void 0 : _j.nameSender,
|
|
101
|
+
subject: (_m = (_l = (_k = foundUser === null || foundUser === void 0 ? void 0 : foundUser.platform) === null || _k === void 0 ? void 0 : _k.platformEmails) === null || _l === void 0 ? void 0 : _l.accountCreatedMail) === null || _m === void 0 ? void 0 : _m.subject,
|
|
102
|
+
text: (_q = (_p = (_o = foundUser === null || foundUser === void 0 ? void 0 : foundUser.platform) === null || _o === void 0 ? void 0 : _o.platformEmails) === null || _p === void 0 ? void 0 : _p.accountCreatedMail) === null || _q === void 0 ? void 0 : _q.message,
|
|
103
|
+
variables: {
|
|
104
|
+
firstName: foundUser === null || foundUser === void 0 ? void 0 : foundUser.firstName,
|
|
105
|
+
lastName: foundUser === null || foundUser === void 0 ? void 0 : foundUser.lastName,
|
|
106
|
+
confirmEmailUrl
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
console.error('Send Confirmation Mail Error:', e);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
async sendForgotPasswordMail(user) {
|
|
116
|
+
var _a, _b, _c;
|
|
117
|
+
try {
|
|
118
|
+
if (user && user.platform) {
|
|
119
|
+
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
120
|
+
const resetPasswordToken = await jwtService.issue({ userId: user.id, platformId: user.platform.id }, { expiresIn: '1d' });
|
|
121
|
+
await strapi.entityService.update(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
122
|
+
data: { resetPasswordToken }
|
|
123
|
+
});
|
|
124
|
+
if (!((_c = (_b = (_a = user === null || user === void 0 ? void 0 : user.platform) === null || _a === void 0 ? void 0 : _a.platformEmails) === null || _b === void 0 ? void 0 : _b.resetPasswordMail) === null || _c === void 0 ? void 0 : _c.fromEmail)) {
|
|
125
|
+
throw new Error('Forgot Password Mail is not configured');
|
|
126
|
+
}
|
|
127
|
+
const resetPasswordUrl = getResetPasswordUrl(user, resetPasswordToken);
|
|
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 === null || user === void 0 ? void 0 : user.firstName,
|
|
136
|
+
lastName: user === null || user === void 0 ? void 0 : user.lastName,
|
|
137
|
+
resetPasswordUrl
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
console.error('Send Forgot Password Mail Error:', e);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const getResetPasswordUrl = (user, resetPasswordToken) => {
|
|
148
|
+
var _a, _b, _c, _d, _e, _f;
|
|
149
|
+
if (!user || !(user === null || user === void 0 ? void 0 : user.platform)) {
|
|
150
|
+
return '';
|
|
151
|
+
}
|
|
152
|
+
if (((_b = (_a = user === null || user === void 0 ? void 0 : user.platform) === null || _a === void 0 ? void 0 : _a.platformEmails) === null || _b === void 0 ? void 0 : _b.resetPasswordUrl) &&
|
|
153
|
+
((_d = (_c = user === null || user === void 0 ? void 0 : user.platform) === null || _c === void 0 ? void 0 : _c.platformEmails) === null || _d === void 0 ? void 0 : _d.resetPasswordUrl.includes('{{resetPasswordToken}}'))) {
|
|
154
|
+
const replacedTokens = user.platform.platformEmails.resetPasswordUrl
|
|
155
|
+
.replace('{{domain}}', (_e = user === null || user === void 0 ? void 0 : user.platform) === null || _e === void 0 ? void 0 : _e.domain)
|
|
156
|
+
.replace('{{resetPasswordToken}}', resetPasswordToken);
|
|
157
|
+
return replacedTokens;
|
|
158
|
+
}
|
|
159
|
+
return `${(_f = user === null || user === void 0 ? void 0 : user.platform) === null || _f === void 0 ? void 0 : _f.domain}/wachtwoord-resetten/${resetPasswordToken}`;
|
|
160
|
+
};
|
|
@@ -8,12 +8,10 @@ const builder_1 = __importDefault(require("./builder"));
|
|
|
8
8
|
const page_type_1 = __importDefault(require("./page-type"));
|
|
9
9
|
const collection_types_1 = __importDefault(require("./collection-types"));
|
|
10
10
|
const template_1 = __importDefault(require("./template"));
|
|
11
|
-
const platform_1 = __importDefault(require("./platform"));
|
|
12
11
|
exports.default = {
|
|
13
12
|
page: page_1.default,
|
|
14
13
|
builder: builder_1.default,
|
|
15
14
|
'page-type': page_type_1.default,
|
|
16
15
|
'collection-types': collection_types_1.default,
|
|
17
|
-
template: template_1.default
|
|
18
|
-
platform: platform_1.default
|
|
16
|
+
template: template_1.default
|
|
19
17
|
};
|
|
@@ -5,24 +5,19 @@ exports.default = {
|
|
|
5
5
|
async findAll() {
|
|
6
6
|
return await strapi.entityService.findMany(constants_1.PLATFORM_UID, { populate: '*' });
|
|
7
7
|
},
|
|
8
|
-
async
|
|
9
|
-
return await strapi.entityService.
|
|
10
|
-
populate: '*'
|
|
11
|
-
filters: {
|
|
12
|
-
pagetype: {
|
|
13
|
-
uid
|
|
14
|
-
}
|
|
15
|
-
}
|
|
8
|
+
async findOneById(id) {
|
|
9
|
+
return await strapi.entityService.findOne(constants_1.PLATFORM_UID, id, {
|
|
10
|
+
populate: '*'
|
|
16
11
|
});
|
|
17
12
|
},
|
|
18
|
-
async findPageTypesByPlatform(
|
|
13
|
+
async findPageTypesByPlatform(id) {
|
|
19
14
|
const results = await strapi.entityService.findMany(constants_1.PLATFORM_UID, {
|
|
20
15
|
populate: {
|
|
21
16
|
pagetype: true
|
|
22
17
|
},
|
|
23
18
|
filters: {
|
|
24
|
-
|
|
25
|
-
$eq:
|
|
19
|
+
id: {
|
|
20
|
+
$eq: id
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
23
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"collectionName": "components_internal_admin_emails",
|
|
3
|
+
"info": {
|
|
4
|
+
"displayName": "AdminEmail",
|
|
5
|
+
"description": ""
|
|
6
|
+
},
|
|
7
|
+
"options": {},
|
|
8
|
+
"attributes": {
|
|
9
|
+
"toEmail": {
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"fromEmail": {
|
|
13
|
+
"type": "string"
|
|
14
|
+
},
|
|
15
|
+
"subject": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"message": {
|
|
19
|
+
"type": "text"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
"resetPasswordUrl": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ACTIONS = exports.CONTENT_ENTITY_MANAGER = exports.USER_ROLE = exports.USER_CONTENT_MANAGER = exports.USER_MODEL = exports.CREATED_BY_ATTRIBUTE = exports.UPDATED_BY_ATTRIBUTE = void 0;
|
|
5
|
+
const utils_1 = require("@strapi/utils");
|
|
6
|
+
_a = utils_1.contentTypes.constants, exports.UPDATED_BY_ATTRIBUTE = _a.UPDATED_BY_ATTRIBUTE, exports.CREATED_BY_ATTRIBUTE = _a.CREATED_BY_ATTRIBUTE;
|
|
7
|
+
exports.USER_MODEL = 'plugin::users-permissions.user';
|
|
8
|
+
exports.USER_CONTENT_MANAGER = 'plugin::users-permissions.contentmanageruser';
|
|
9
|
+
exports.USER_ROLE = 'plugin::users-permissions.role';
|
|
10
|
+
exports.CONTENT_ENTITY_MANAGER = 'plugin::content-manager.entity-manager';
|
|
11
|
+
exports.ACTIONS = {
|
|
12
|
+
read: 'plugin::content-manager.explorer.read',
|
|
13
|
+
create: 'plugin::content-manager.explorer.create',
|
|
14
|
+
edit: 'plugin::content-manager.explorer.update',
|
|
15
|
+
delete: 'plugin::content-manager.explorer.delete'
|
|
16
|
+
};
|