@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/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",
@@ -7,18 +7,26 @@ export const platformForgotPassword = {
7
7
  async resolve(parent, args, context) {
8
8
  await validateForgotPasswordSchema(args.input);
9
9
 
10
- const { email, platformId } = args.input;
10
+ const { email, domain } = args.input;
11
11
 
12
12
  const user = await strapi.query(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
+
22
+ if (!user) {
23
+ {
24
+ message: 'Email has been sent';
25
+ }
26
+ }
27
+
21
28
  await strapi.service('plugin::page-builder.email').sendForgotPasswordMail(user);
29
+
22
30
  return {
23
31
  message: 'Email has been sent'
24
32
  };
@@ -7,14 +7,17 @@ export const platformLogin = {
7
7
  async resolve(parent, args, context) {
8
8
  await validateLoginSchema(args.input);
9
9
 
10
- const { email, password, platformId } = args.input;
10
+ const { email, password, domain } = args.input;
11
11
 
12
12
  const user = await strapi.query(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
 
@@ -41,7 +44,9 @@ export const platformLogin = {
41
44
  const sanitizedUser = sanitize.contentAPI.output(user, strapi.getModel(USER_MODEL), {
42
45
  auth: false
43
46
  });
44
- const jwt = await strapi.service('plugin::users-permissions.jwt').issue({ id: user.id, platformId: platformId });
47
+ const jwt = await strapi
48
+ .service('plugin::users-permissions.jwt')
49
+ .issue({ id: user.id, platformId: user.platform.id });
45
50
 
46
51
  return {
47
52
  user: sanitizedUser,
@@ -2,7 +2,7 @@ import { sanitize } from '@strapi/utils';
2
2
  import { errors } from '@strapi/utils';
3
3
  import { USER_MODEL } from '../../constants';
4
4
  import { validateRegisterSchema } from '../../schemas';
5
- const { ApplicationError } = errors;
5
+ const { ApplicationError, NotFoundError } = errors;
6
6
 
7
7
  export const platformRegister = {
8
8
  async resolve(parent, args, context) {
@@ -11,7 +11,19 @@ export const platformRegister = {
11
11
 
12
12
  await validateRegisterSchema(args.input);
13
13
 
14
- const { email, platformId } = args.input;
14
+ const { email, domain } = args.input;
15
+
16
+ const platform = await strapi.query('api::platform.platform').findOne({
17
+ where: {
18
+ domain: domain.toLowerCase()
19
+ }
20
+ });
21
+
22
+ console.log(platform);
23
+
24
+ if (!platform) {
25
+ throw new NotFoundError('Platform not found');
26
+ }
15
27
 
16
28
  const role = await strapi
17
29
  .query('plugin::users-permissions.role')
@@ -24,11 +36,11 @@ export const platformRegister = {
24
36
  where: {
25
37
  $and: [
26
38
  {
27
- email
39
+ email: email.toLowerCase()
28
40
  },
29
41
  {
30
42
  platform: {
31
- id: platformId
43
+ id: platform.id
32
44
  }
33
45
  }
34
46
  ]
@@ -43,7 +55,7 @@ export const platformRegister = {
43
55
  ...args.input,
44
56
  role: role.id,
45
57
  categories: args.input.categories,
46
- platform: platformId,
58
+ platform: platform.id,
47
59
  email: email.toLowerCase(),
48
60
  provider: 'local',
49
61
  confirmed: false,
@@ -2,14 +2,14 @@ export const LoginInput = `
2
2
  input LoginInput {
3
3
  email: String!
4
4
  password: String!
5
- platformId: ID!
5
+ domain: String!
6
6
  }
7
7
  `;
8
8
 
9
9
  export const ForgotPasswordInput = `
10
10
  input ForgotPasswordInput {
11
11
  email: String!
12
- platformId: ID!
12
+ domain: String!
13
13
  }`;
14
14
 
15
15
  export const RegisterInput = `
@@ -27,7 +27,7 @@ input RegisterInput {
27
27
  phone: String
28
28
  subscribeToNewsletter: Boolean
29
29
  categories: [ID]
30
- platformId: ID!
30
+ domain: String!
31
31
  }
32
32
  `;
33
33
 
@@ -57,7 +57,6 @@ type User {
57
57
  confirmed: Boolean
58
58
  blocked: Boolean
59
59
  activated: Boolean
60
- platformId: ID!
61
60
  }
62
61
  `;
63
62
 
@@ -3,18 +3,18 @@ import { validateYupSchema, yup } from '@strapi/utils';
3
3
  const registerSchema = yup.object({
4
4
  email: yup.string().email().required(),
5
5
  password: yup.string().required(),
6
- platformId: yup.number().required()
6
+ domain: yup.string().required()
7
7
  });
8
8
 
9
9
  export const loginSchema = yup.object({
10
10
  email: yup.string().email().required(),
11
11
  password: yup.string().required(),
12
- platformId: yup.number().required()
12
+ domain: yup.string().required()
13
13
  });
14
14
 
15
15
  export const forgotPasswordSchema = yup.object({
16
16
  email: yup.string().email().required(),
17
- platformId: yup.number().required()
17
+ domain: yup.string().required()
18
18
  });
19
19
 
20
20
  export const resetPasswordSchema = yup.object({