@strapi/plugin-users-permissions 0.0.0-next.f45143c5e2a8a9d85691d0abf79a3f42024a0c71 → 0.0.0-next.f7babb775ed9a7e18d8351cb7f74c63e016323c4

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 (52) hide show
  1. package/admin/src/components/BoundRoute/index.js +5 -3
  2. package/admin/src/components/FormModal/Input/index.js +6 -3
  3. package/admin/src/components/FormModal/index.js +13 -10
  4. package/admin/src/components/Permissions/PermissionRow/CheckboxWrapper.js +1 -1
  5. package/admin/src/components/Permissions/PermissionRow/SubCategory.js +26 -5
  6. package/admin/src/components/Permissions/PermissionRow/index.js +4 -2
  7. package/admin/src/components/Permissions/index.js +5 -2
  8. package/admin/src/components/Policies/index.js +3 -2
  9. package/admin/src/components/UsersPermissions/index.js +8 -5
  10. package/admin/src/{permissions.js → constants.js} +1 -3
  11. package/admin/src/contexts/UsersPermissionsContext/index.js +1 -0
  12. package/admin/src/hooks/index.js +1 -1
  13. package/admin/src/hooks/useFetchRole/index.js +6 -3
  14. package/admin/src/hooks/useForm/index.js +6 -8
  15. package/admin/src/hooks/usePlugins.js +71 -0
  16. package/admin/src/hooks/useRolesList/index.js +22 -20
  17. package/admin/src/index.js +7 -5
  18. package/admin/src/pages/AdvancedSettings/index.js +27 -28
  19. package/admin/src/pages/AdvancedSettings/utils/api.js +2 -3
  20. package/admin/src/pages/AdvancedSettings/utils/schema.js +1 -1
  21. package/admin/src/pages/EmailTemplates/components/EmailForm.js +14 -13
  22. package/admin/src/pages/EmailTemplates/components/EmailTable.js +9 -7
  23. package/admin/src/pages/EmailTemplates/index.js +16 -17
  24. package/admin/src/pages/EmailTemplates/utils/api.js +2 -3
  25. package/admin/src/pages/EmailTemplates/utils/schema.js +1 -1
  26. package/admin/src/pages/Providers/index.js +31 -32
  27. package/admin/src/pages/Providers/utils/api.js +2 -3
  28. package/admin/src/pages/Providers/utils/forms.js +1 -1
  29. package/admin/src/pages/Roles/{CreatePage/index.js → CreatePage.js} +26 -23
  30. package/admin/src/pages/Roles/{EditPage/index.js → EditPage.js} +23 -20
  31. package/admin/src/pages/Roles/ListPage/components/TableBody.js +4 -3
  32. package/admin/src/pages/Roles/ListPage/index.js +31 -34
  33. package/admin/src/pages/Roles/ListPage/utils/api.js +3 -4
  34. package/admin/src/pages/Roles/{ProtectedCreatePage/index.js → ProtectedCreatePage.js} +6 -3
  35. package/admin/src/pages/Roles/{ProtectedEditPage/index.js → ProtectedEditPage.js} +6 -3
  36. package/admin/src/pages/Roles/{ProtectedListPage/index.js → ProtectedListPage.js} +5 -3
  37. package/admin/src/pages/Roles/{CreatePage/utils/schema.js → constants.js} +2 -4
  38. package/admin/src/pages/Roles/index.js +9 -6
  39. package/admin/src/translations/ru.json +50 -26
  40. package/admin/src/utils/index.js +1 -2
  41. package/documentation/content-api.yaml +22 -14
  42. package/jest.config.front.js +2 -0
  43. package/package.json +23 -26
  44. package/server/middlewares/rateLimit.js +41 -21
  45. package/server/register.js +7 -1
  46. package/server/services/providers-registry.js +1 -1
  47. package/server/strategies/users-permissions.js +1 -8
  48. package/admin/src/hooks/usePlugins/index.js +0 -67
  49. package/admin/src/hooks/usePlugins/init.js +0 -5
  50. package/admin/src/hooks/usePlugins/reducer.js +0 -34
  51. package/admin/src/pages/Roles/EditPage/utils/schema.js +0 -9
  52. package/admin/src/utils/getRequestURL.js +0 -5
@@ -2,55 +2,79 @@
2
2
  "BoundRoute.title": "Связать путь с",
3
3
  "EditForm.inputSelect.description.role": "При регистрации пользователи будут иметь выбранную роль.",
4
4
  "EditForm.inputSelect.label.role": "Роль по умолчанию для новых пользователей",
5
- "EditForm.inputToggle.description.email": "Запретить пользователю создавать несколько учетных записей, используя один и тот же адрес электронной почты с различными провайдерами аутентификации.",
5
+ "EditForm.inputToggle.description.email": "Запретить пользователю создавать несколько учётных записей, используя один и тот же адрес электронной почты, у разных поставщиков аутентификации.",
6
6
  "EditForm.inputToggle.description.email-confirmation": "Если включено (ON), при регистрации пользователи будут получать письмо для подтверждения адреса электронной почты.",
7
- "EditForm.inputToggle.description.email-confirmation-redirection": "Укажите URL-адрес для перенаправления после подтверждения адреса электронной почты.",
8
- "EditForm.inputToggle.description.email-reset-password": "URL-адрес страницы сброса пароля вашего приложения",
9
- "EditForm.inputToggle.description.sign-up": "Когда выключенно (OFF) процесс регистрации запрещен. Никто не может зарегистрироваться, независимо от провайдера.",
10
- "EditForm.inputToggle.label.email": "Одна учетная запись на адрес электронной почты",
7
+ "EditForm.inputToggle.description.email-confirmation-redirection": "Укажите URL-адрес для перенаправления пользователей после подтверждения адреса электронной почты.",
8
+ "EditForm.inputToggle.description.email-reset-password": "URL-адрес страницы для сброса пароля учётной записи пользователя",
9
+ "EditForm.inputToggle.description.sign-up": "Если выключено (OFF), процесс регистрации пользователей запрещен. Никто не может зарегистрироваться, независимо от провайдера.",
10
+ "EditForm.inputToggle.label.email": "Одна учётная запись на один адрес электронной почты",
11
11
  "EditForm.inputToggle.label.email-confirmation": "Включить подтверждение по электронной почте",
12
12
  "EditForm.inputToggle.label.email-confirmation-redirection": "URL-адрес для перенаправления",
13
13
  "EditForm.inputToggle.label.email-reset-password": "Страница сброса пароля",
14
- "EditForm.inputToggle.label.sign-up": "Включить регистрацию",
15
- "Email.template.email_confirmation": "Подтверждение адреса электронной почты",
14
+ "EditForm.inputToggle.label.sign-up": "Включить регистрации",
15
+ "EditForm.inputToggle.placeholder.email-confirmation-redirection": "например: https://yourfrontend.com/email-confirmation-redirection",
16
+ "EditForm.inputToggle.placeholder.email-reset-password": "например: https://yourfrontend.com/reset-password",
17
+ "EditPage.form.roles": "Сведения о роли",
18
+ "Email.template.data.loaded": "Шаблоны автоматических писем для электронной почты были загружены",
19
+ "Email.template.email_confirmation": "Адреса электронной почты с письмом о подтверждении",
20
+ "Email.template.form.edit.label": "Редактировать шаблон",
21
+ "Email.template.table.action.label": "действие",
22
+ "Email.template.table.icon.label": "иконка",
23
+ "Email.template.table.name.label": "название",
24
+ "Form.advancedSettings.data.loaded": "Данные расширенных настроек были загружены",
16
25
  "HeaderNav.link.advancedSettings": "Расширенные настройки",
17
26
  "HeaderNav.link.emailTemplates": "Шаблоны писем",
18
27
  "HeaderNav.link.providers": "Провайдеры",
19
- "Plugin.permissions.plugins.description": "Определить действия доступные для плагина {name}.",
20
- "Plugins.header.description": "В списке выводятся только действия, связанные с маршрутом.",
21
- "Plugins.header.title": "Доступы",
22
- "Policies.header.hint": "Выберите действия приложения или плагина и щелкните значок шестеренки, чтобы отобразить связанный маршрут",
28
+ "Plugin.permissions.plugins.description": "Определите все разрешенные действия для плагина {name}.",
29
+ "Plugins.header.description": "Ниже перечислены только действия, связанные с путём.",
30
+ "Plugins.header.title": "Разрешения",
31
+ "Policies.header.hint": "Выберите действия приложения или плагина и нажмите на значок шестерёнки, чтобы отобразить связанный путь",
23
32
  "Policies.header.title": "Расширенные настройки",
24
- "PopUpForm.Email.email_templates.inputDescription": "Если вы не уверены как использовать переменные, {link}",
33
+ "PopUpForm.Email.email_templates.inputDescription": "Если вы не уверены, как использовать переменные {link}",
25
34
  "PopUpForm.Email.link.documentation": "ознакомьтесь с нашей документацией.",
26
- "PopUpForm.Email.options.from.email.label": "Адрес отправителя",
35
+ "PopUpForm.Email.options.from.email.label": "Электронная почта отправителя",
27
36
  "PopUpForm.Email.options.from.email.placeholder": "kai@doe.com",
28
37
  "PopUpForm.Email.options.from.name.label": "Имя отправителя",
29
38
  "PopUpForm.Email.options.from.name.placeholder": "Kai Doe",
30
39
  "PopUpForm.Email.options.message.label": "Сообщение",
31
40
  "PopUpForm.Email.options.object.label": "Тема",
32
41
  "PopUpForm.Email.options.object.placeholder": "Пожалуйста, подтвердите свой адрес электронной почты для %APP_NAME%",
33
- "PopUpForm.Email.options.response_email.label": "Адрес для ответа",
34
- "PopUpForm.Email.options.response_email.placeholder": "kai@doe.com",
35
- "PopUpForm.Providers.enabled.description": "Если отключено, пользователи не смогут использовать этот провайдер.",
36
- "PopUpForm.Providers.enabled.label": "Включить",
37
- "PopUpForm.Providers.key.label": "Client ID",
42
+ "PopUpForm.Email.options.response_email.label": "Электронная почта для ответов",
43
+ "PopUpForm.Email.options.response_email.placeholder": "paul@example.com",
44
+ "PopUpForm.Providers.enabled.description": "Если этот параметр отключен, пользователи не смогут использовать этого поставщика.",
45
+ "PopUpForm.Providers.enabled.label": "Включено",
46
+ "PopUpForm.Providers.key.label": "ID клиента",
38
47
  "PopUpForm.Providers.key.placeholder": "TEXT",
39
- "PopUpForm.Providers.redirectURL.front-end.label": "URL-адрес перенаправления для вашего приложения",
40
- "PopUpForm.Providers.redirectURL.label": "URL перенаправления, который нужно добавить в {provider} конфигурации приложения",
48
+ "PopUpForm.Providers.redirectURL.front-end.label": "URL-адрес перенаправления на ваше приложение",
49
+ "PopUpForm.Providers.redirectURL.label": "URL-адрес перенаправления, который нужно добавить в {provider} конфигурации приложения",
41
50
  "PopUpForm.Providers.secret.label": "Client Secret",
42
51
  "PopUpForm.Providers.secret.placeholder": "TEXT",
43
- "PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
52
+ "PopUpForm.Providers.subdomain.label": "Хост URI (Поддомен)",
44
53
  "PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
45
54
  "PopUpForm.header.edit.email-templates": "Редактировать шаблон письма",
46
55
  "PopUpForm.header.edit.providers": "Редактировать провайдера",
56
+ "Providers.data.loaded": "Провайдеры были загружены",
57
+ "Providers.status": "Статус",
58
+ "Roles.empty": "У вас пока нет никаких ролей.",
59
+ "Roles.empty.search": "Ни одна роль не соответствует поисковому запросу.",
47
60
  "Settings.roles.deleted": "Роль удалена",
48
61
  "Settings.roles.edited": "Роль отредактирована",
49
- "Settings.section-label": "Плагин Пользователи и разрешения",
50
- "notification.success.submit": "Настройки обновлены",
51
- "plugin.description.long": "Защитите ваш API с помощью процесса полной аутентификации, основанном на JWT. Этот плагин также включает в себя возможности ACL (Access Control List), которые позволят вам настраивать доступы для групп пользователей.",
52
- "plugin.description.short": "Защитите ваш API с помощью процесса полной аутентификации, основанном на JWT",
53
- "plugin.name": "Роли и доступы",
62
+ "Settings.section-label": "Плагин «Пользователи и Разрешения»",
63
+ "components.Input.error.validation.email": "Неверный адрес электронной почты",
64
+ "components.Input.error.validation.json": "Это не соответствует формату JSON",
65
+ "components.Input.error.validation.max": "Значение слишком велико.",
66
+ "components.Input.error.validation.maxLength": "Значение слишком длинное.",
67
+ "components.Input.error.validation.min": "Значение слишком мало.",
68
+ "components.Input.error.validation.minLength": "Значение слишком короткое.",
69
+ "components.Input.error.validation.minSupMax": "Не может быть выше",
70
+ "components.Input.error.validation.regex": "Значение не соответствует регулярному выражению.",
71
+ "components.Input.error.validation.required": "Это значение является обязательным.",
72
+ "components.Input.error.validation.unique": "Это значение уже используется.",
73
+ "notification.success.submit": "Настройки были обновлены",
74
+ "page.title": "Настройки — Роли",
75
+ "plugin.description.long": "Защитите свой API с помощью полноценного процесса аутентификации, основанного на JWT. Этот плагин также имеет настройки стратегии ACL, которые позволяют вам управлять разрешениями между группами пользователей.",
76
+ "plugin.description.short": "Защитите свой API с помощью полноценного процесса аутентификации, основанного на JWT.",
77
+ "plugin.name": "Пользователи и Разрешения",
54
78
  "popUpWarning.button.cancel": "Отменить",
55
79
  "popUpWarning.button.confirm": "Подтвердить",
56
80
  "popUpWarning.title": "Пожалуйста подтвердите",
@@ -1,4 +1,3 @@
1
1
  export { default as cleanPermissions } from './cleanPermissions';
2
- export { default as getRequestURL } from './getRequestURL';
3
- export { default as getTrad } from './getTrad';
4
2
  export { default as formatPolicies } from './formatPolicies';
3
+ export { default as getTrad } from './getTrad';
@@ -12,8 +12,16 @@ tags:
12
12
  url: 'https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html'
13
13
 
14
14
  paths:
15
- '/connect/(.*)':
15
+ /connect/{provider}:
16
16
  get:
17
+ parameters:
18
+ - name: provider
19
+ in: path
20
+ required: true
21
+ description: Provider name
22
+ schema:
23
+ type: string
24
+ pattern: '.*'
17
25
  tags:
18
26
  - Users-Permissions - Auth
19
27
  summary: Login with a provider
@@ -148,7 +156,7 @@ paths:
148
156
  type: object
149
157
  properties:
150
158
  ok:
151
- type: enum
159
+ type: string
152
160
  enum: [true]
153
161
  default:
154
162
  description: Error
@@ -273,7 +281,7 @@ paths:
273
281
  email:
274
282
  type: string
275
283
  sent:
276
- type: enum
284
+ type: string
277
285
  enum: [true]
278
286
  default:
279
287
  description: Error
@@ -381,7 +389,7 @@ paths:
381
389
  type: object
382
390
  properties:
383
391
  ok:
384
- type: enum
392
+ type: string
385
393
  enum: [true]
386
394
  default:
387
395
  description: Error
@@ -456,7 +464,7 @@ paths:
456
464
  type: object
457
465
  properties:
458
466
  ok:
459
- type: enum
467
+ type: string
460
468
  enum: [true]
461
469
  default:
462
470
  description: Error
@@ -485,7 +493,7 @@ paths:
485
493
  type: object
486
494
  properties:
487
495
  ok:
488
- type: enum
496
+ type: string
489
497
  enum: [true]
490
498
  default:
491
499
  description: Error
@@ -779,9 +787,11 @@ components:
779
787
  type:
780
788
  type: string
781
789
  createdAt:
782
- type: datetime
790
+ type: string
791
+ format: date-time
783
792
  updatedAt:
784
- type: datetime
793
+ type: string
794
+ format: date-time
785
795
 
786
796
  Users-Permissions-User:
787
797
  type: object
@@ -805,10 +815,12 @@ components:
805
815
  type: boolean
806
816
  example: false
807
817
  createdAt:
808
- type: datetime
818
+ type: string
819
+ format: date-time
809
820
  example: '2022-06-02T08:32:06.258Z'
810
821
  updatedAt:
811
- type: datetime
822
+ type: string
823
+ format: date-time
812
824
  example: '2022-06-02T08:32:06.267Z'
813
825
 
814
826
  Users-Permissions-UserRegistration:
@@ -839,10 +851,6 @@ components:
839
851
  type: boolean
840
852
  policy:
841
853
  type: string
842
-
843
- parameters:
844
- responses:
845
- examples:
846
854
  requestBodies:
847
855
  Users-Permissions-RoleRequest:
848
856
  required: true
@@ -2,4 +2,6 @@
2
2
 
3
3
  module.exports = {
4
4
  preset: '../../../jest-preset.front.js',
5
+ displayName: 'Users & Permissions plugin',
6
+ setupFilesAfterEnv: ['./tests/setup.js'],
5
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-users-permissions",
3
- "version": "0.0.0-next.f45143c5e2a8a9d85691d0abf79a3f42024a0c71",
3
+ "version": "0.0.0-next.f7babb775ed9a7e18d8351cb7f74c63e016323c4",
4
4
  "description": "Protect your API with a full-authentication process based on JWT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,48 +29,45 @@
29
29
  "lint": "run -T eslint ."
30
30
  },
31
31
  "dependencies": {
32
- "@strapi/design-system": "1.6.6",
33
- "@strapi/helper-plugin": "0.0.0-next.f45143c5e2a8a9d85691d0abf79a3f42024a0c71",
34
- "@strapi/icons": "1.6.6",
35
- "@strapi/utils": "0.0.0-next.f45143c5e2a8a9d85691d0abf79a3f42024a0c71",
32
+ "@strapi/design-system": "1.8.2",
33
+ "@strapi/helper-plugin": "0.0.0-next.f7babb775ed9a7e18d8351cb7f74c63e016323c4",
34
+ "@strapi/icons": "1.8.2",
35
+ "@strapi/utils": "0.0.0-next.f7babb775ed9a7e18d8351cb7f74c63e016323c4",
36
36
  "bcryptjs": "2.4.3",
37
- "formik": "2.2.9",
37
+ "formik": "2.4.0",
38
38
  "grant-koa": "5.4.8",
39
39
  "immer": "9.0.19",
40
40
  "jsonwebtoken": "9.0.0",
41
41
  "jwk-to-pem": "2.0.5",
42
- "koa": "^2.13.4",
42
+ "koa": "2.13.4",
43
43
  "koa2-ratelimit": "^1.1.2",
44
44
  "lodash": "4.17.21",
45
- "prop-types": "^15.7.2",
45
+ "prop-types": "^15.8.1",
46
46
  "purest": "4.0.2",
47
- "react-intl": "6.3.2",
48
- "react-query": "3.24.3",
49
- "react-redux": "8.0.5",
47
+ "react-intl": "6.4.1",
48
+ "react-query": "3.39.3",
49
+ "react-redux": "8.1.1",
50
50
  "url-join": "4.0.1",
51
- "yup": "^0.32.9"
51
+ "yup": "0.32.9"
52
52
  },
53
53
  "devDependencies": {
54
- "@testing-library/dom": "8.19.0",
55
- "@testing-library/react": "12.1.4",
56
- "@testing-library/react-hooks": "8.0.1",
54
+ "@testing-library/dom": "9.2.0",
55
+ "@testing-library/react": "14.0.0",
57
56
  "@testing-library/user-event": "14.4.3",
58
- "history": "^4.9.0",
59
- "msw": "1.0.1",
60
- "react": "^17.0.2",
61
- "react-dom": "^17.0.2",
57
+ "msw": "1.2.1",
58
+ "react": "^18.2.0",
59
+ "react-dom": "^18.2.0",
62
60
  "react-router-dom": "5.3.4",
63
- "react-test-renderer": "^17.0.2",
64
61
  "styled-components": "5.3.3"
65
62
  },
66
63
  "peerDependencies": {
67
- "react": "^17.0.2",
68
- "react-dom": "^17.0.2",
69
- "react-router-dom": "^5.3.4",
70
- "styled-components": "^5.3.3"
64
+ "react": "^17.0.0 || ^18.0.0",
65
+ "react-dom": "^17.0.0 || ^18.0.0",
66
+ "react-router-dom": "5.3.4",
67
+ "styled-components": "5.3.3"
71
68
  },
72
69
  "engines": {
73
- "node": ">=14.19.1 <=18.x.x",
70
+ "node": ">=16.0.0 <=20.x.x",
74
71
  "npm": ">=6.0.0"
75
72
  },
76
73
  "strapi": {
@@ -80,5 +77,5 @@
80
77
  "required": true,
81
78
  "kind": "plugin"
82
79
  },
83
- "gitHead": "f45143c5e2a8a9d85691d0abf79a3f42024a0c71"
80
+ "gitHead": "f7babb775ed9a7e18d8351cb7f74c63e016323c4"
84
81
  }
@@ -1,27 +1,47 @@
1
1
  'use strict';
2
2
 
3
+ const utils = require('@strapi/utils');
4
+ const { isString, has, toLower } = require('lodash/fp');
5
+ const path = require('path');
6
+
7
+ const { RateLimitError } = utils.errors;
8
+
3
9
  module.exports =
4
10
  (config, { strapi }) =>
5
11
  async (ctx, next) => {
6
- const ratelimit = require('koa2-ratelimit').RateLimit;
7
-
8
- const message = [
9
- {
10
- messages: [
11
- {
12
- id: 'Auth.form.error.ratelimit',
13
- message: 'Too many attempts, please try again in a minute.',
14
- },
15
- ],
16
- },
17
- ];
18
-
19
- return ratelimit.middleware({
20
- interval: 1 * 60 * 1000,
21
- max: 5,
22
- prefixKey: `${ctx.request.path}:${ctx.request.ip}`,
23
- message,
24
- ...strapi.config.get('plugin.users-permissions.ratelimit'),
25
- ...config,
26
- })(ctx, next);
12
+ let rateLimitConfig = strapi.config.get('plugin.users-permissions.ratelimit');
13
+
14
+ if (!rateLimitConfig) {
15
+ rateLimitConfig = {
16
+ enabled: true,
17
+ };
18
+ }
19
+
20
+ if (!has('enabled', rateLimitConfig)) {
21
+ rateLimitConfig.enabled = true;
22
+ }
23
+
24
+ if (rateLimitConfig.enabled === true) {
25
+ const rateLimit = require('koa2-ratelimit').RateLimit;
26
+
27
+ const userIdentifier = toLower(ctx.request.body.email) || 'unknownIdentifier';
28
+ const requestPath = isString(ctx.request.path)
29
+ ? toLower(path.normalize(ctx.request.path))
30
+ : 'invalidPath';
31
+
32
+ const loadConfig = {
33
+ interval: { min: 5 },
34
+ max: 5,
35
+ prefixKey: `${userIdentifier}:${requestPath}:${ctx.request.ip}`,
36
+ handler() {
37
+ throw new RateLimitError();
38
+ },
39
+ ...rateLimitConfig,
40
+ ...config,
41
+ };
42
+
43
+ return rateLimit.middleware(loadConfig)(ctx, next);
44
+ }
45
+
46
+ return next();
27
47
  };
@@ -18,6 +18,12 @@ module.exports = ({ strapi }) => {
18
18
  const specPath = path.join(__dirname, '../documentation/content-api.yaml');
19
19
  const spec = fs.readFileSync(specPath, 'utf8');
20
20
 
21
- strapi.plugin('documentation').service('documentation').registerDoc(spec);
21
+ strapi
22
+ .plugin('documentation')
23
+ .service('override')
24
+ .registerOverride(spec, {
25
+ pluginOrigin: 'users-permissions',
26
+ excludeFromGeneration: ['users-permissions'],
27
+ });
22
28
  }
23
29
  };
@@ -176,7 +176,7 @@ const getInitialProviders = ({ purest }) => ({
176
176
  const vk = purest({ provider: 'vk' });
177
177
 
178
178
  return vk
179
- .get('users.get')
179
+ .get('users')
180
180
  .auth(accessToken)
181
181
  .qs({ id: query.raw.user_id, v: '5.122' })
182
182
  .request()
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { castArray, map, every, pipe, isEmpty } = require('lodash/fp');
3
+ const { castArray, map, every, pipe } = require('lodash/fp');
4
4
  const { ForbiddenError, UnauthorizedError } = require('@strapi/utils').errors;
5
5
 
6
6
  const { getService } = require('../utils');
@@ -80,13 +80,6 @@ const authenticate = async (ctx) => {
80
80
  const verify = async (auth, config) => {
81
81
  const { credentials: user, ability } = auth;
82
82
 
83
- strapi.telemetry.send('didReceiveAPIRequest', {
84
- eventProperties: {
85
- authenticationMethod: auth?.strategy?.name,
86
- isAuthenticated: !isEmpty(user),
87
- },
88
- });
89
-
90
83
  if (!config.scope) {
91
84
  if (!user) {
92
85
  // A non authenticated user cannot access routes that do not have a scope
@@ -1,67 +0,0 @@
1
- import { useCallback, useEffect, useReducer } from 'react';
2
- import { useNotification, useFetchClient } from '@strapi/helper-plugin';
3
- import get from 'lodash/get';
4
- import init from './init';
5
- import pluginId from '../../pluginId';
6
- import { cleanPermissions } from '../../utils';
7
- import reducer, { initialState } from './reducer';
8
-
9
- const usePlugins = (shouldFetchData = true) => {
10
- const toggleNotification = useNotification();
11
- const [{ permissions, routes, isLoading }, dispatch] = useReducer(reducer, initialState, () =>
12
- init(initialState, shouldFetchData)
13
- );
14
- const fetchClient = useFetchClient();
15
-
16
- const fetchPlugins = useCallback(async () => {
17
- try {
18
- dispatch({
19
- type: 'GET_DATA',
20
- });
21
-
22
- const [{ permissions }, { routes }] = await Promise.all(
23
- [`/${pluginId}/permissions`, `/${pluginId}/routes`].map(async (endpoint) => {
24
- const res = await fetchClient.get(endpoint);
25
-
26
- return res.data;
27
- })
28
- );
29
-
30
- dispatch({
31
- type: 'GET_DATA_SUCCEEDED',
32
- permissions: cleanPermissions(permissions),
33
- routes,
34
- });
35
- } catch (err) {
36
- const message = get(err, ['response', 'payload', 'message'], 'An error occured');
37
-
38
- dispatch({
39
- type: 'GET_DATA_ERROR',
40
- });
41
-
42
- if (message !== 'Forbidden') {
43
- toggleNotification({
44
- type: 'warning',
45
- message,
46
- });
47
- }
48
- }
49
-
50
- // eslint-disable-next-line react-hooks/exhaustive-deps
51
- }, [toggleNotification]);
52
-
53
- useEffect(() => {
54
- if (shouldFetchData) {
55
- fetchPlugins();
56
- }
57
- }, [fetchPlugins, shouldFetchData]);
58
-
59
- return {
60
- permissions,
61
- routes,
62
- getData: fetchPlugins,
63
- isLoading,
64
- };
65
- };
66
-
67
- export default usePlugins;
@@ -1,5 +0,0 @@
1
- const init = (initialState, shouldFetchData) => {
2
- return { ...initialState, isLoading: shouldFetchData };
3
- };
4
-
5
- export default init;
@@ -1,34 +0,0 @@
1
- /* eslint-disable consistent-return */
2
- import produce from 'immer';
3
-
4
- export const initialState = {
5
- permissions: {},
6
- routes: {},
7
- isLoading: true,
8
- };
9
-
10
- const reducer = (state, action) =>
11
- produce(state, (draftState) => {
12
- switch (action.type) {
13
- case 'GET_DATA': {
14
- draftState.isLoading = true;
15
- draftState.permissions = {};
16
- draftState.routes = {};
17
- break;
18
- }
19
- case 'GET_DATA_SUCCEEDED': {
20
- draftState.permissions = action.permissions;
21
- draftState.routes = action.routes;
22
- draftState.isLoading = false;
23
- break;
24
- }
25
- case 'GET_DATA_ERROR': {
26
- draftState.isLoading = false;
27
- break;
28
- }
29
- default:
30
- return draftState;
31
- }
32
- });
33
-
34
- export default reducer;
@@ -1,9 +0,0 @@
1
- import * as yup from 'yup';
2
- import { translatedErrors } from '@strapi/helper-plugin';
3
-
4
- const schema = yup.object().shape({
5
- name: yup.string().required(translatedErrors.required),
6
- description: yup.string().required(translatedErrors.required),
7
- });
8
-
9
- export default schema;
@@ -1,5 +0,0 @@
1
- import pluginId from '../pluginId';
2
-
3
- const getRequestURL = (endPoint) => `/${pluginId}/${endPoint}`;
4
-
5
- export default getRequestURL;