@webbio/strapi-plugin-page-builder 0.9.10-authentication → 0.9.11-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.10-authentication",
3
+ "version": "0.9.11-authentication",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -37,18 +37,18 @@ export default async ({ strapi }: { strapi: Strapi }) => {
37
37
  async beforeUpdate(event) {
38
38
  if (event.params.data.id) {
39
39
  const userToUpdate = await strapi.entityService?.findOne(USER_PERMISSION_USER_PLUGIN, event.params.data.id, {
40
- populate: { platform: { populate: { platformMails: { populate: '*' } } } }
40
+ populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
41
41
  });
42
42
  if (userToUpdate) {
43
43
  if (event.params.data.activateUser && event.params.data.confirmed && !userToUpdate.confirmMailSend) {
44
44
  await strapi.service(PAGE_BUILDER_EMAIL_PLUGIN).sendMail({
45
45
  // @ts-ignore strapi typings
46
- from: userToUpdate.platform.platformMails.accountAcceptedMail.fromEmail,
46
+ from: userToUpdate.platform.platformEmails.accountAcceptedMail.fromEmail,
47
47
  to: event.params.data.email,
48
48
  // @ts-ignore
49
- subject: userToUpdate.platform.platformMails.accountAcceptedMail.subject,
49
+ subject: userToUpdate.platform.platformEmails.accountAcceptedMail.subject,
50
50
  // @ts-ignore
51
- text: userToUpdate.platform.platformMails.accountAcceptedMail.message,
51
+ text: userToUpdate.platform.platformEmails.accountAcceptedMail.message,
52
52
  firstName: event.params.data.firstName,
53
53
  lastName: event.params.data.lastName
54
54
  });
@@ -1,18 +1,18 @@
1
1
  {
2
- "kind": "collectionType",
3
- "collectionName": "categories",
4
- "info": {
5
- "singularName": "category",
6
- "pluralName": "categories",
7
- "displayName": "category"
8
- },
9
- "options": {
10
- "draftAndPublish": false,
11
- "comment": ""
12
- },
13
- "attributes": {
14
- "title": {
15
- "type": "string"
16
- }
17
- }
18
- }
2
+ "kind": "collectionType",
3
+ "collectionName": "categories",
4
+ "info": {
5
+ "singularName": "category",
6
+ "pluralName": "categories",
7
+ "displayName": "category"
8
+ },
9
+ "options": {
10
+ "draftAndPublish": false,
11
+ "comment": ""
12
+ },
13
+ "attributes": {
14
+ "title": {
15
+ "type": "string"
16
+ }
17
+ }
18
+ }
@@ -3,6 +3,7 @@ import { Strapi } from '@strapi/strapi';
3
3
  import { PAGE_UID } from '../../shared/utils/constants';
4
4
 
5
5
  import { ForbiddenError as ApolloForbiddenError } from 'apollo-server-koa';
6
+ import { getConfig } from '../utils/strapi';
6
7
 
7
8
  const getPageByPath = (strapi: Strapi) => {
8
9
  const typeDefs = () => {
@@ -112,8 +113,11 @@ const getPageByPath = (strapi: Strapi) => {
112
113
  };
113
114
  };
114
115
 
116
+ const pageBuilderConfig = getConfig();
117
+
115
118
  const resolversConfig = {
116
119
  'Query.getPageByPath': {
120
+ policies: pageBuilderConfig?.privateContent === true ? ['plugin::page-builder.isAuthorizedForPage'] : [],
117
121
  auth: false
118
122
  }
119
123
  };
@@ -1 +1,5 @@
1
- export default {};
1
+ import isAuthorizedForPage from './isAuthorizedPage';
2
+
3
+ export default {
4
+ isAuthorizedForPage
5
+ };
@@ -0,0 +1,11 @@
1
+ const isAuthorizedForPage = (policyContext, _config, { strapi }) => {
2
+ const pageToken = policyContext.http.request.headers['x-strapi-page-secret'];
3
+ const pageEnvToken = process.env.STRAPI_PAGE_SECRET;
4
+
5
+ if (pageToken && pageEnvToken && pageToken === pageEnvToken) {
6
+ return true;
7
+ }
8
+ return false;
9
+ };
10
+
11
+ export default isAuthorizedForPage;
@@ -92,13 +92,13 @@
92
92
  "relation": "oneToOne",
93
93
  "target": "api::platform.platform"
94
94
  },
95
- "isPrivate": {
96
- "pluginOptions": {
97
- "i18n": {
98
- "localized": true
99
- }
100
- },
101
- "type": "boolean"
102
- }
95
+ "isPrivate": {
96
+ "pluginOptions": {
97
+ "i18n": {
98
+ "localized": true
99
+ }
100
+ },
101
+ "type": "boolean"
102
+ }
103
103
  }
104
104
  }
@@ -43,24 +43,24 @@ export default {
43
43
  },
44
44
  async sendAdminMail(user) {
45
45
  const foundUser = await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
46
- populate: { platform: { populate: { platformMails: { populate: '*' } } } }
46
+ populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
47
47
  });
48
48
  await this.sendMail({
49
49
  // @ts-ignore we all love strapi typings
50
- from: foundUser.platform.platformMails.adminEmail.fromEmail,
50
+ from: foundUser.platform.platformEmails.adminEmail.fromEmail,
51
51
  // @ts-ignore
52
- to: foundUser.platform.platformMails.adminEmail.toMail,
52
+ to: foundUser.platform.platformEmails.adminEmail.toMail,
53
53
  // @ts-ignore
54
- subject: foundUser.platform.platformMails.adminEmail.subject,
54
+ subject: foundUser.platform.platformEmails.adminEmail.subject,
55
55
  // @ts-ignore
56
- text: foundUser.platform.platformMails.adminEmail.message,
56
+ text: foundUser.platform.platformEmails.adminEmail.message,
57
57
  firstName: user.firstName,
58
58
  lastName: user.lastName
59
59
  });
60
60
  },
61
61
  async sendConfirmationEmail(user) {
62
62
  const foundUser = await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
63
- populate: { platform: { populate: { platformMails: { populate: '*' } } } }
63
+ populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
64
64
  });
65
65
  if (foundUser && foundUser.platform) {
66
66
  const jwtService = strapi.plugin('users-permissions').service('jwt');
@@ -78,12 +78,12 @@ export default {
78
78
 
79
79
  await this.sendMail({
80
80
  // @ts-ignore
81
- from: foundUser.platform.platformMails.accountCreatedMail.fromEmail,
81
+ from: foundUser.platform.platformEmails.accountCreatedMail.fromEmail,
82
82
  to: user.email,
83
83
  // @ts-ignore
84
- subject: foundUser.platform.platformMails.accountCreatedMail.subject,
84
+ subject: foundUser.platform.platformEmails.accountCreatedMail.subject,
85
85
  // @ts-ignore
86
- text: foundUser.platform.platformMails.accountCreatedMail.message,
86
+ text: foundUser.platform.platformEmails.accountCreatedMail.message,
87
87
  firstName: user.firstName,
88
88
  lastName: user.lastName,
89
89
  confirmationUrl: activateUrl
@@ -107,12 +107,12 @@ export default {
107
107
 
108
108
  await this.sendMail({
109
109
  // @ts-ignore
110
- from: user.platform.platformMails.resetPasswordMail.fromEmail,
110
+ from: user.platform.platformEmails.resetPasswordMail.fromEmail,
111
111
  to: user.email,
112
112
  // @ts-ignore
113
- subject: user.platform.platformMails.resetPasswordMail.subject,
113
+ subject: user.platform.platformEmails.resetPasswordMail.subject,
114
114
  // @ts-ignore
115
- text: user.platform.platformMails.resetPasswordMail.message,
115
+ text: user.platform.platformEmails.resetPasswordMail.message,
116
116
  firstName: user.firstName,
117
117
  lastName: user.lastName,
118
118
  confirmationUrl: activateUrl
@@ -1,23 +1,22 @@
1
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
- }
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
22
  }
23
-
@@ -1,23 +1,22 @@
1
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
- }
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
22
  }
23
-
@@ -1,30 +1,30 @@
1
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
- }
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
30
  }
@@ -10,7 +10,7 @@ export const platformForgotPassword = {
10
10
  const { email, platformId } = args.input;
11
11
 
12
12
  const user = await strapi.query(USER_MODEL).findOne({
13
- populate: { platform: { populate: { platformMails: { populate: true } } } },
13
+ populate: { platform: { populate: { platformEmails: { populate: true } } } },
14
14
  where: {
15
15
  email: email.toLowerCase(),
16
16
  platform: {