@webbio/strapi-plugin-page-builder 0.9.14-authentication → 0.9.15-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.14-authentication",
3
+ "version": "0.9.15-authentication",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -8,16 +8,21 @@ const { UnauthorizedError } = utils_1.errors;
8
8
  exports.platformForgotPassword = {
9
9
  async resolve(parent, args, context) {
10
10
  await (0, schemas_1.validateForgotPasswordSchema)(args.input);
11
- const { email, platformId } = args.input;
11
+ const { email, domain } = args.input;
12
12
  const user = await strapi.query(constants_1.USER_MODEL).findOne({
13
13
  populate: { platform: { populate: { platformEmails: { populate: true } } } },
14
14
  where: {
15
15
  email: email.toLowerCase(),
16
16
  platform: {
17
- id: platformId
17
+ domain: domain.toLowerCase()
18
18
  }
19
19
  }
20
20
  });
21
+ if (!user) {
22
+ {
23
+ message: 'Email has been sent';
24
+ }
25
+ }
21
26
  await strapi.service('plugin::page-builder.email').sendForgotPasswordMail(user);
22
27
  return {
23
28
  message: 'Email has been sent'
@@ -8,13 +8,16 @@ const { UnauthorizedError } = utils_1.errors;
8
8
  exports.platformLogin = {
9
9
  async resolve(parent, args, context) {
10
10
  await (0, schemas_1.validateLoginSchema)(args.input);
11
- const { email, password, platformId } = args.input;
11
+ const { email, password, domain } = args.input;
12
12
  const user = await strapi.query(constants_1.USER_MODEL).findOne({
13
13
  where: {
14
14
  email: email.toLowerCase(),
15
15
  platform: {
16
- id: platformId
16
+ domain: domain.toLowerCase()
17
17
  }
18
+ },
19
+ populate: {
20
+ platform: true
18
21
  }
19
22
  });
20
23
  if (user == null) {
@@ -35,7 +38,9 @@ exports.platformLogin = {
35
38
  const sanitizedUser = utils_1.sanitize.contentAPI.output(user, strapi.getModel(constants_1.USER_MODEL), {
36
39
  auth: false
37
40
  });
38
- const jwt = await strapi.service('plugin::users-permissions.jwt').issue({ id: user.id, platformId: platformId });
41
+ const jwt = await strapi
42
+ .service('plugin::users-permissions.jwt')
43
+ .issue({ id: user.id, platformId: user.platform.id });
39
44
  return {
40
45
  user: sanitizedUser,
41
46
  jwt
@@ -5,13 +5,22 @@ const utils_1 = require("@strapi/utils");
5
5
  const utils_2 = require("@strapi/utils");
6
6
  const constants_1 = require("../../constants");
7
7
  const schemas_1 = require("../../schemas");
8
- const { ApplicationError } = utils_2.errors;
8
+ const { ApplicationError, NotFoundError } = utils_2.errors;
9
9
  exports.platformRegister = {
10
10
  async resolve(parent, args, context) {
11
11
  const pluginStore = await strapi.store({ type: 'plugin', name: 'users-permissions' });
12
12
  const settings = await pluginStore.get({ key: 'advanced' });
13
13
  await (0, schemas_1.validateRegisterSchema)(args.input);
14
- const { email, platformId } = args.input;
14
+ const { email, domain } = args.input;
15
+ const platform = await strapi.query('api::platform.platform').findOne({
16
+ where: {
17
+ domain: domain.toLowerCase()
18
+ }
19
+ });
20
+ console.log(platform);
21
+ if (!platform) {
22
+ throw new NotFoundError('Platform not found');
23
+ }
15
24
  const role = await strapi
16
25
  .query('plugin::users-permissions.role')
17
26
  .findOne({ where: { type: settings.default_role } });
@@ -22,11 +31,11 @@ exports.platformRegister = {
22
31
  where: {
23
32
  $and: [
24
33
  {
25
- email
34
+ email: email.toLowerCase()
26
35
  },
27
36
  {
28
37
  platform: {
29
- id: platformId
38
+ id: platform.id
30
39
  }
31
40
  }
32
41
  ]
@@ -39,7 +48,7 @@ exports.platformRegister = {
39
48
  ...args.input,
40
49
  role: role.id,
41
50
  categories: args.input.categories,
42
- platform: platformId,
51
+ platform: platform.id,
43
52
  email: email.toLowerCase(),
44
53
  provider: 'local',
45
54
  confirmed: false,
@@ -5,13 +5,13 @@ exports.LoginInput = `
5
5
  input LoginInput {
6
6
  email: String!
7
7
  password: String!
8
- platformId: ID!
8
+ domain: String!
9
9
  }
10
10
  `;
11
11
  exports.ForgotPasswordInput = `
12
12
  input ForgotPasswordInput {
13
13
  email: String!
14
- platformId: ID!
14
+ domain: String!
15
15
  }`;
16
16
  exports.RegisterInput = `
17
17
  input RegisterInput {
@@ -28,7 +28,7 @@ input RegisterInput {
28
28
  phone: String
29
29
  subscribeToNewsletter: Boolean
30
30
  categories: [ID]
31
- platformId: ID!
31
+ domain: String!
32
32
  }
33
33
  `;
34
34
  exports.LoginResponse = `
@@ -54,7 +54,6 @@ type User {
54
54
  confirmed: Boolean
55
55
  blocked: Boolean
56
56
  activated: Boolean
57
- platformId: ID!
58
57
  }
59
58
  `;
60
59
  exports.ResetPassword = `
@@ -5,16 +5,16 @@ const utils_1 = require("@strapi/utils");
5
5
  const registerSchema = utils_1.yup.object({
6
6
  email: utils_1.yup.string().email().required(),
7
7
  password: utils_1.yup.string().required(),
8
- platformId: utils_1.yup.number().required()
8
+ domain: utils_1.yup.string().required()
9
9
  });
10
10
  exports.loginSchema = utils_1.yup.object({
11
11
  email: utils_1.yup.string().email().required(),
12
12
  password: utils_1.yup.string().required(),
13
- platformId: utils_1.yup.number().required()
13
+ domain: utils_1.yup.string().required()
14
14
  });
15
15
  exports.forgotPasswordSchema = utils_1.yup.object({
16
16
  email: utils_1.yup.string().email().required(),
17
- platformId: utils_1.yup.number().required()
17
+ domain: utils_1.yup.string().required()
18
18
  });
19
19
  exports.resetPasswordSchema = utils_1.yup.object({
20
20
  password: utils_1.yup.string().required(),