@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/dist/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",
@@ -31,18 +31,18 @@ exports.default = async ({ strapi }) => {
31
31
  var _a;
32
32
  if (event.params.data.id) {
33
33
  const userToUpdate = await ((_a = strapi.entityService) === null || _a === void 0 ? void 0 : _a.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, event.params.data.id, {
34
- populate: { platform: { populate: { platformMails: { populate: '*' } } } }
34
+ populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
35
35
  }));
36
36
  if (userToUpdate) {
37
37
  if (event.params.data.activateUser && event.params.data.confirmed && !userToUpdate.confirmMailSend) {
38
38
  await strapi.service(constants_1.PAGE_BUILDER_EMAIL_PLUGIN).sendMail({
39
39
  // @ts-ignore strapi typings
40
- from: userToUpdate.platform.platformMails.accountAcceptedMail.fromEmail,
40
+ from: userToUpdate.platform.platformEmails.accountAcceptedMail.fromEmail,
41
41
  to: event.params.data.email,
42
42
  // @ts-ignore
43
- subject: userToUpdate.platform.platformMails.accountAcceptedMail.subject,
43
+ subject: userToUpdate.platform.platformEmails.accountAcceptedMail.subject,
44
44
  // @ts-ignore
45
- text: userToUpdate.platform.platformMails.accountAcceptedMail.message,
45
+ text: userToUpdate.platform.platformEmails.accountAcceptedMail.message,
46
46
  firstName: event.params.data.firstName,
47
47
  lastName: event.params.data.lastName
48
48
  });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const constants_1 = require("../../shared/utils/constants");
4
4
  const apollo_server_koa_1 = require("apollo-server-koa");
5
+ const strapi_1 = require("../utils/strapi");
5
6
  const getPageByPath = (strapi) => {
6
7
  const typeDefs = () => {
7
8
  return `
@@ -93,8 +94,10 @@ const getPageByPath = (strapi) => {
93
94
  }
94
95
  };
95
96
  };
97
+ const pageBuilderConfig = (0, strapi_1.getConfig)();
96
98
  const resolversConfig = {
97
99
  'Query.getPageByPath': {
100
+ policies: (pageBuilderConfig === null || pageBuilderConfig === void 0 ? void 0 : pageBuilderConfig.privateContent) === true ? ['plugin::page-builder.isAuthorizedForPage'] : [],
98
101
  auth: false
99
102
  }
100
103
  };
@@ -1,3 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {};
6
+ const isAuthorizedPage_1 = __importDefault(require("./isAuthorizedPage"));
7
+ exports.default = {
8
+ isAuthorizedForPage: isAuthorizedPage_1.default
9
+ };
@@ -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;
@@ -57,24 +57,24 @@ exports.default = {
57
57
  },
58
58
  async sendAdminMail(user) {
59
59
  const foundUser = await strapi.entityService.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
60
- populate: { platform: { populate: { platformMails: { populate: '*' } } } }
60
+ populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
61
61
  });
62
62
  await this.sendMail({
63
63
  // @ts-ignore we all love strapi typings
64
- from: foundUser.platform.platformMails.adminEmail.fromEmail,
64
+ from: foundUser.platform.platformEmails.adminEmail.fromEmail,
65
65
  // @ts-ignore
66
- to: foundUser.platform.platformMails.adminEmail.toMail,
66
+ to: foundUser.platform.platformEmails.adminEmail.toMail,
67
67
  // @ts-ignore
68
- subject: foundUser.platform.platformMails.adminEmail.subject,
68
+ subject: foundUser.platform.platformEmails.adminEmail.subject,
69
69
  // @ts-ignore
70
- text: foundUser.platform.platformMails.adminEmail.message,
70
+ text: foundUser.platform.platformEmails.adminEmail.message,
71
71
  firstName: user.firstName,
72
72
  lastName: user.lastName
73
73
  });
74
74
  },
75
75
  async sendConfirmationEmail(user) {
76
76
  const foundUser = await strapi.entityService.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, user.id, {
77
- populate: { platform: { populate: { platformMails: { populate: '*' } } } }
77
+ populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
78
78
  });
79
79
  if (foundUser && foundUser.platform) {
80
80
  const jwtService = strapi.plugin('users-permissions').service('jwt');
@@ -89,12 +89,12 @@ exports.default = {
89
89
  const activateUrl = `${foundUser.platform.domain}/api/page-builder/activate/${confirmationToken}`;
90
90
  await this.sendMail({
91
91
  // @ts-ignore
92
- from: foundUser.platform.platformMails.accountCreatedMail.fromEmail,
92
+ from: foundUser.platform.platformEmails.accountCreatedMail.fromEmail,
93
93
  to: user.email,
94
94
  // @ts-ignore
95
- subject: foundUser.platform.platformMails.accountCreatedMail.subject,
95
+ subject: foundUser.platform.platformEmails.accountCreatedMail.subject,
96
96
  // @ts-ignore
97
- text: foundUser.platform.platformMails.accountCreatedMail.message,
97
+ text: foundUser.platform.platformEmails.accountCreatedMail.message,
98
98
  firstName: user.firstName,
99
99
  lastName: user.lastName,
100
100
  confirmationUrl: activateUrl
@@ -112,12 +112,12 @@ exports.default = {
112
112
  const activateUrl = `${user.platform.domain}/api/page-builder/reset/${resetPasswordToken}`;
113
113
  await this.sendMail({
114
114
  // @ts-ignore
115
- from: user.platform.platformMails.resetPasswordMail.fromEmail,
115
+ from: user.platform.platformEmails.resetPasswordMail.fromEmail,
116
116
  to: user.email,
117
117
  // @ts-ignore
118
- subject: user.platform.platformMails.resetPasswordMail.subject,
118
+ subject: user.platform.platformEmails.resetPasswordMail.subject,
119
119
  // @ts-ignore
120
- text: user.platform.platformMails.resetPasswordMail.message,
120
+ text: user.platform.platformEmails.resetPasswordMail.message,
121
121
  firstName: user.firstName,
122
122
  lastName: user.lastName,
123
123
  confirmationUrl: activateUrl
@@ -10,7 +10,7 @@ exports.platformForgotPassword = {
10
10
  await (0, schemas_1.validateForgotPasswordSchema)(args.input);
11
11
  const { email, platformId } = args.input;
12
12
  const user = await strapi.query(constants_1.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: {