@webbio/strapi-plugin-page-builder 0.9.13-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.
Files changed (34) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/server/content-types/category/category.js +0 -0
  3. package/dist/server/content-types/category/category.json +27 -0
  4. package/dist/server/content-types/page-version/schema.json +16 -0
  5. package/dist/server/controllers/page-version.js +7 -0
  6. package/dist/server/graphql/page-by-path.js +1 -1
  7. package/dist/server/graphql/page-by-slug.js +89 -0
  8. package/dist/server/middlewares/private-content.js +13 -0
  9. package/dist/server/routes/page-version.js +7 -0
  10. package/dist/server/services/authentication.js +186 -0
  11. package/dist/server/services/page-version.js +7 -0
  12. package/dist/server/services/private-content/acceptedMail/acceptMail.email.template.text.js +12 -0
  13. package/dist/server/services/private-content/acceptedMail/acceptMail.interface.js +2 -0
  14. package/dist/server/services/private-content/graphql/resolvers/find.js +0 -0
  15. package/dist/server/services/private-content/graphql/resolvers/findAll.js +0 -0
  16. package/dist/server/services/private-content/graphql/resolvers/findOnePage.js +1 -1
  17. package/dist/server/services/private-content/graphql/resolvers/findPage.js +5 -4
  18. package/dist/server/services/private-content/graphql/resolvers/forgot-password.js +7 -2
  19. package/dist/server/services/private-content/graphql/resolvers/login.js +8 -3
  20. package/dist/server/services/private-content/graphql/resolvers/register.js +14 -5
  21. package/dist/server/services/private-content/graphql/types/index.js +3 -4
  22. package/dist/server/services/private-content/schemas/index.js +3 -3
  23. package/dist/server/utils/graphql.js +100 -0
  24. package/dist/server/utils/paginationValidation.js +31 -0
  25. package/dist/tsconfig.server.tsbuildinfo +1 -1
  26. package/package.json +1 -1
  27. package/server/graphql/page-by-path.ts +1 -1
  28. package/server/services/private-content/graphql/resolvers/findOnePage.ts +1 -1
  29. package/server/services/private-content/graphql/resolvers/findPage.ts +4 -4
  30. package/server/services/private-content/graphql/resolvers/forgot-password.ts +10 -2
  31. package/server/services/private-content/graphql/resolvers/login.ts +8 -3
  32. package/server/services/private-content/graphql/resolvers/register.ts +17 -5
  33. package/server/services/private-content/graphql/types/index.ts +3 -4
  34. package/server/services/private-content/schemas/index.ts +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webbio/strapi-plugin-page-builder",
3
- "version": "0.9.13-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",
@@ -77,7 +77,7 @@ const getPageByPath = (strapi: Strapi) => {
77
77
  const results: Record<string, any> = await getPage();
78
78
 
79
79
  if (Object.values(results)?.filter(Boolean).length > 0) {
80
- if (!results?.platform?.isPrivate && !results.isPrivate) {
80
+ if (!results?.platform?.isPrivate && !results?.isPrivate) {
81
81
  return results;
82
82
  }
83
83
  if (
@@ -13,7 +13,7 @@ export const page = {
13
13
  const sanitizedQuery = await sanitize.contentAPI.query(populatedArgs, strapi.contentType(PAGE_UID));
14
14
  const value = await strapi.entityService!.findOne(uid, args.id, omit('id', sanitizedQuery));
15
15
  // @ts-ignore Strapi types are the best
16
- if (!value?.platform?.isPrivate && !value.isPrivate) {
16
+ if (!value?.platform?.isPrivate && !value?.isPrivate) {
17
17
  return toEntityResponse(value, { args: transformedArgs, resourceUID: uid });
18
18
  }
19
19
 
@@ -22,14 +22,14 @@ export const pages = {
22
22
  // @ts-ignore
23
23
  const filteredItems = value.filter((item) => {
24
24
  // @ts-ignore
25
- if (item.platform.isPrivate === true && user.platform.id === item.platform.id) {
25
+ if (item.platform?.isPrivate === true && user.platform.id === item.platform.id) {
26
26
  return item;
27
27
  }
28
- if (item.isPrivate === true && user.platform.id === item.platform.id) {
28
+ if (item?.isPrivate === true && user.platform.id === item.platform.id) {
29
29
  return item;
30
30
  }
31
31
  // @ts-ignore
32
- if (item.platform.isPrivate !== true && item.isPrivate !== true) {
32
+ if (item.platform?.isPrivate !== true && item?.isPrivate !== true) {
33
33
  return item;
34
34
  }
35
35
  });
@@ -38,7 +38,7 @@ export const pages = {
38
38
  }
39
39
 
40
40
  // @ts-ignore
41
- const filteredItems = value.filter((item) => item.platform.isPrivate !== true && item.isPrivate !== true);
41
+ const filteredItems = value.filter((item) => item.platform?.isPrivate !== true && item?.isPrivate !== true);
42
42
 
43
43
  return toEntityResponseCollection(filteredItems, { args: transformedArgs, resourceUID: uid });
44
44
  }
@@ -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({