@webbio/strapi-plugin-page-builder 0.9.15-authentication → 0.9.17-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.15-authentication",
3
+ "version": "0.9.17-authentication",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -1,8 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
- activateUser(ctx) {
5
- return strapi.service('plugin::page-builder.private-content').activateUser(ctx.params.token);
4
+ async activateUser(ctx) {
5
+ try {
6
+ const user = await strapi.service('plugin::page-builder.private-content').activateUser(ctx.params.token);
7
+ const callbackUrl = `${user.platform.domain}/login`;
8
+ return ctx.redirect(callbackUrl);
9
+ }
10
+ catch (error) {
11
+ console.log(ctx);
12
+ return ctx.unauthorized('User is already confirmed or token is invalid');
13
+ }
6
14
  },
7
15
  removeInactiveUsers(ctx) {
8
16
  return strapi.service('plugin::page-builder.private-content').removeInactiveUsers();
@@ -21,9 +21,6 @@
21
21
  "type": "component",
22
22
  "repeatable": false,
23
23
  "component": "internal.platform-email"
24
- },
25
- "isPrivate": {
26
- "type": "boolean"
27
24
  }
28
25
  }
29
26
  }
@@ -86,7 +86,7 @@ exports.default = {
86
86
  data: { confirmationToken: confirmationToken }
87
87
  });
88
88
  // @ts-ignore
89
- const activateUrl = `${foundUser.platform.domain}/api/page-builder/activate/${confirmationToken}`;
89
+ const activateUrl = `${strapi.config.server.url}/api/page-builder/activate/${confirmationToken}`;
90
90
  await this.sendMail({
91
91
  // @ts-ignore
92
92
  from: foundUser.platform.platformEmails.accountCreatedMail.fromEmail,
@@ -109,6 +109,7 @@ exports.default = {
109
109
  // @ts-ignore
110
110
  data: { resetPasswordToken }
111
111
  });
112
+ // @ts-ignore
112
113
  const activateUrl = `${user.platform.domain}/api/page-builder/reset/${resetPasswordToken}`;
113
114
  await this.sendMail({
114
115
  // @ts-ignore
@@ -17,7 +17,6 @@ exports.platformRegister = {
17
17
  domain: domain.toLowerCase()
18
18
  }
19
19
  });
20
- console.log(platform);
21
20
  if (!platform) {
22
21
  throw new NotFoundError('Platform not found');
23
22
  }
@@ -22,26 +22,37 @@ exports.default = {
22
22
  return (pageBuilderConfig === null || pageBuilderConfig === void 0 ? void 0 : pageBuilderConfig.privateContent) === true;
23
23
  },
24
24
  async activateUser(token) {
25
- const jwtService = strapi.plugin('users-permissions').service('jwt');
26
- const decodedToken = await jwtService.verify(token);
27
- if (decodedToken) {
28
- const user = await strapi.query('plugin::users-permissions.user').findOne({
29
- where: {
30
- id: decodedToken.userId,
31
- platform: {
32
- id: decodedToken.platformId
25
+ try {
26
+ const jwtService = strapi.plugin('users-permissions').service('jwt');
27
+ const decodedToken = await jwtService.verify(token);
28
+ if (decodedToken) {
29
+ const user = await strapi.query('plugin::users-permissions.user').findOne({
30
+ where: {
31
+ id: decodedToken.userId,
32
+ platform: {
33
+ id: decodedToken.platformId
34
+ }
35
+ },
36
+ populate: {
37
+ platform: true
33
38
  }
34
- }
35
- });
36
- if (!user.confirmed && user.confirmationToken && user.confirmationToken === token) {
37
- await strapi.entityService.update('plugin::users-permissions.user', user.id, {
38
- // @ts-ignore
39
- data: { confirmed: true, confirmationToken: null }
40
39
  });
41
- await strapi.service('plugin::page-builder.email').sendAdminMail(user);
42
- return ' User has been created';
40
+ if ((user === null || user === void 0 ? void 0 : user.confirmed) === false && (user === null || user === void 0 ? void 0 : user.confirmationToken) != null && (user === null || user === void 0 ? void 0 : user.confirmationToken) === token) {
41
+ await strapi.entityService.update('plugin::users-permissions.user', user.id, {
42
+ // @ts-ignore
43
+ data: { confirmed: true, confirmationToken: null }
44
+ });
45
+ await strapi.service('plugin::page-builder.email').sendAdminMail(user);
46
+ return user;
47
+ }
48
+ else {
49
+ throw new Error("Error activating user. User doesn't exist or is already activated.");
50
+ }
43
51
  }
44
- throw new Error('User already activated');
52
+ }
53
+ catch (error) {
54
+ console.error(error);
55
+ throw error;
45
56
  }
46
57
  },
47
58
  async removeInactiveUsers() {