@strapi/plugin-users-permissions 5.55.1 → 5.57.0

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 (90) hide show
  1. package/dist/server/controllers/auth.js +8 -8
  2. package/dist/server/controllers/auth.js.map +1 -1
  3. package/dist/server/controllers/auth.mjs +8 -7
  4. package/dist/server/controllers/auth.mjs.map +1 -1
  5. package/dist/server/controllers/validation/email-template.js +1 -4
  6. package/dist/server/controllers/validation/email-template.js.map +1 -1
  7. package/dist/server/controllers/validation/email-template.mjs +1 -3
  8. package/dist/server/controllers/validation/email-template.mjs.map +1 -1
  9. package/dist/server/graphql/mutations/auth/change-password.js +1 -1
  10. package/dist/server/graphql/mutations/auth/change-password.js.map +1 -1
  11. package/dist/server/graphql/mutations/auth/change-password.mjs +1 -1
  12. package/dist/server/graphql/mutations/auth/change-password.mjs.map +1 -1
  13. package/dist/server/graphql/mutations/auth/email-confirmation.js +1 -1
  14. package/dist/server/graphql/mutations/auth/email-confirmation.js.map +1 -1
  15. package/dist/server/graphql/mutations/auth/email-confirmation.mjs +1 -1
  16. package/dist/server/graphql/mutations/auth/email-confirmation.mjs.map +1 -1
  17. package/dist/server/graphql/mutations/auth/forgot-password.js +1 -1
  18. package/dist/server/graphql/mutations/auth/forgot-password.js.map +1 -1
  19. package/dist/server/graphql/mutations/auth/forgot-password.mjs +1 -1
  20. package/dist/server/graphql/mutations/auth/forgot-password.mjs.map +1 -1
  21. package/dist/server/graphql/mutations/auth/login.js +1 -1
  22. package/dist/server/graphql/mutations/auth/login.js.map +1 -1
  23. package/dist/server/graphql/mutations/auth/login.mjs +1 -1
  24. package/dist/server/graphql/mutations/auth/login.mjs.map +1 -1
  25. package/dist/server/graphql/mutations/auth/register.js +1 -1
  26. package/dist/server/graphql/mutations/auth/register.js.map +1 -1
  27. package/dist/server/graphql/mutations/auth/register.mjs +1 -1
  28. package/dist/server/graphql/mutations/auth/register.mjs.map +1 -1
  29. package/dist/server/graphql/mutations/auth/reset-password.js +1 -1
  30. package/dist/server/graphql/mutations/auth/reset-password.js.map +1 -1
  31. package/dist/server/graphql/mutations/auth/reset-password.mjs +1 -1
  32. package/dist/server/graphql/mutations/auth/reset-password.mjs.map +1 -1
  33. package/dist/server/graphql/mutations/crud/role/create-role.js +1 -1
  34. package/dist/server/graphql/mutations/crud/role/create-role.js.map +1 -1
  35. package/dist/server/graphql/mutations/crud/role/create-role.mjs +1 -1
  36. package/dist/server/graphql/mutations/crud/role/create-role.mjs.map +1 -1
  37. package/dist/server/graphql/mutations/crud/user/create-user.js +1 -1
  38. package/dist/server/graphql/mutations/crud/user/create-user.js.map +1 -1
  39. package/dist/server/graphql/mutations/crud/user/create-user.mjs +1 -1
  40. package/dist/server/graphql/mutations/crud/user/create-user.mjs.map +1 -1
  41. package/dist/server/graphql/mutations/crud/user/update-user.js +1 -1
  42. package/dist/server/graphql/mutations/crud/user/update-user.js.map +1 -1
  43. package/dist/server/graphql/mutations/crud/user/update-user.mjs +1 -1
  44. package/dist/server/graphql/mutations/crud/user/update-user.mjs.map +1 -1
  45. package/dist/server/graphql/utils.js +4 -4
  46. package/dist/server/graphql/utils.js.map +1 -1
  47. package/dist/server/graphql/utils.mjs +4 -4
  48. package/dist/server/graphql/utils.mjs.map +1 -1
  49. package/dist/server/middlewares/rateLimit.js +4 -4
  50. package/dist/server/middlewares/rateLimit.js.map +1 -1
  51. package/dist/server/middlewares/rateLimit.mjs +4 -4
  52. package/dist/server/middlewares/rateLimit.mjs.map +1 -1
  53. package/dist/server/services/providers-registry.js +3 -3
  54. package/dist/server/services/providers-registry.mjs +2 -2
  55. package/dist/server/services/providers.js +3 -3
  56. package/dist/server/services/providers.mjs +2 -2
  57. package/dist/server/services/user.js +9 -9
  58. package/dist/server/services/user.js.map +1 -1
  59. package/dist/server/services/user.mjs +8 -8
  60. package/dist/server/services/user.mjs.map +1 -1
  61. package/dist/server/services/users-permissions.js +6 -9
  62. package/dist/server/services/users-permissions.js.map +1 -1
  63. package/dist/server/services/users-permissions.mjs +5 -7
  64. package/dist/server/services/users-permissions.mjs.map +1 -1
  65. package/dist/server/strategies/users-permissions.js +8 -7
  66. package/dist/server/strategies/users-permissions.js.map +1 -1
  67. package/dist/server/strategies/users-permissions.mjs +8 -7
  68. package/dist/server/strategies/users-permissions.mjs.map +1 -1
  69. package/dist/server/utils/sanitize/sanitizers.js +1 -1
  70. package/dist/server/utils/sanitize/sanitizers.js.map +1 -1
  71. package/dist/server/utils/sanitize/sanitizers.mjs +1 -1
  72. package/dist/server/utils/sanitize/sanitizers.mjs.map +1 -1
  73. package/package.json +7 -7
  74. package/server/src/controllers/auth.js +4 -4
  75. package/server/src/controllers/validation/email-template.js +1 -2
  76. package/server/src/graphql/mutations/auth/change-password.js +1 -1
  77. package/server/src/graphql/mutations/auth/email-confirmation.js +1 -1
  78. package/server/src/graphql/mutations/auth/forgot-password.js +1 -1
  79. package/server/src/graphql/mutations/auth/login.js +1 -1
  80. package/server/src/graphql/mutations/auth/register.js +1 -1
  81. package/server/src/graphql/mutations/auth/reset-password.js +1 -1
  82. package/server/src/graphql/mutations/crud/role/create-role.js +1 -1
  83. package/server/src/graphql/mutations/crud/user/create-user.js +1 -1
  84. package/server/src/graphql/mutations/crud/user/update-user.js +1 -1
  85. package/server/src/graphql/utils.js +3 -3
  86. package/server/src/middlewares/rateLimit.js +3 -3
  87. package/server/src/services/user.js +3 -3
  88. package/server/src/services/users-permissions.js +3 -5
  89. package/server/src/strategies/users-permissions.js +13 -9
  90. package/server/src/utils/sanitize/sanitizers.js +1 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { toPlainObject } = require('lodash/fp');
3
+ const { toPlainObject } = require('lodash');
4
4
 
5
5
  const { checkBadRequest } = require('../../../utils');
6
6
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { getOr } = require('lodash/fp');
3
+ const { get } = require('lodash');
4
4
 
5
5
  /**
6
6
  * Throws an ApolloError if context body contains a bad request
@@ -8,10 +8,10 @@ const { getOr } = require('lodash/fp');
8
8
  * @throws ApolloError if the body is a bad request
9
9
  */
10
10
  function checkBadRequest(contextBody) {
11
- const statusCode = getOr(200, 'statusCode', contextBody);
11
+ const statusCode = get(contextBody, 'statusCode', 200);
12
12
 
13
13
  if (statusCode !== 200) {
14
- const errorMessage = getOr('Bad Request', 'error', contextBody);
14
+ const errorMessage = get(contextBody, 'error', 'Bad Request');
15
15
 
16
16
  const exception = new Error(errorMessage);
17
17
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  const path = require('path');
4
4
  const utils = require('@strapi/utils');
5
- const { isString, has, toLower } = require('lodash/fp');
5
+ const { toLower, isString, has } = require('lodash');
6
6
 
7
7
  const { RateLimitError } = utils.errors;
8
8
 
@@ -47,7 +47,7 @@ const routeUsesEmailIdentifier = (requestPath) => {
47
47
  */
48
48
  const normalizeRequestPathForRateLimit = (requestPath) => {
49
49
  const normalized = path.posix.normalize(requestPath);
50
- const lower = toLower(normalized);
50
+ const lower = normalized.toLowerCase();
51
51
  return lower.replace(/\/+$/, '') || '/';
52
52
  };
53
53
 
@@ -102,7 +102,7 @@ module.exports =
102
102
  };
103
103
  }
104
104
 
105
- if (!has('enabled', rateLimitConfig)) {
105
+ if (!has(rateLimitConfig, 'enabled')) {
106
106
  rateLimitConfig.enabled = true;
107
107
  }
108
108
 
@@ -11,12 +11,12 @@ const bcrypt = require('bcryptjs');
11
11
  const urlJoin = require('url-join');
12
12
 
13
13
  const { sanitize, ALLOWED_QUERY_PARAM_KEYS } = require('@strapi/utils');
14
- const { toNumber, getOr, pick } = require('lodash/fp');
14
+ const { pick, get, toNumber } = require('lodash');
15
15
  const { getService } = require('../utils');
16
16
 
17
17
  const USER_MODEL_UID = 'plugin::users-permissions.user';
18
18
 
19
- const pickAllowedQueryParams = pick(ALLOWED_QUERY_PARAM_KEYS);
19
+ const pickAllowedQueryParams = (params) => pick(params, ALLOWED_QUERY_PARAM_KEYS);
20
20
 
21
21
  const getSessionManager = () => {
22
22
  const manager = strapi.sessionManager;
@@ -52,7 +52,7 @@ module.exports = ({ strapi }) => ({
52
52
  for (const key in values) {
53
53
  if (attributes[key] && attributes[key].type === 'password') {
54
54
  // Check if a custom encryption.rounds has been set on the password attribute
55
- const rounds = toNumber(getOr(10, 'encryption.rounds', attributes[key]));
55
+ const rounds = toNumber(get(attributes[key], 'encryption.rounds', 10));
56
56
  values[key] = await bcrypt.hash(values[key], rounds);
57
57
  }
58
58
  }
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const _ = require('lodash');
4
- const { filter, map, pipe, prop } = require('lodash/fp');
5
4
  const urlJoin = require('url-join');
6
5
  const {
7
6
  template: { createStrictInterpolationRegExp },
@@ -193,10 +192,9 @@ module.exports = ({ strapi }) => ({
193
192
  if (permissionsFoundInDB.length === 0) {
194
193
  // create default permissions
195
194
  for (const role of roles) {
196
- const toCreate = pipe(
197
- filter(({ roleType }) => roleType === role.type || roleType === null),
198
- map(prop('action'))
199
- )(DEFAULT_PERMISSIONS);
195
+ const toCreate = DEFAULT_PERMISSIONS.filter(
196
+ ({ roleType }) => roleType === role.type || roleType === null
197
+ ).map(({ action }) => action);
200
198
 
201
199
  await Promise.all(
202
200
  toCreate.map((action) => {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { castArray, map, every, pipe } = require('lodash/fp');
3
+ const { map, every } = require('lodash');
4
4
  const { ForbiddenError, UnauthorizedError } = require('@strapi/utils').errors;
5
5
 
6
6
  const { getService } = require('../utils');
@@ -43,7 +43,11 @@ const authenticate = async (ctx) => {
43
43
  // Fetch user's permissions
44
44
  const permissions = await Promise.resolve(user.role.id)
45
45
  .then(getService('permission').findRolePermissions)
46
- .then(map(getService('permission').toContentAPIPermission));
46
+ .then((permissions) =>
47
+ map(permissions, (permission) =>
48
+ getService('permission').toContentAPIPermission(permission)
49
+ )
50
+ );
47
51
 
48
52
  // Generate an ability (content API engine) based on the given permissions
49
53
  const ability = await strapi.contentAPI.permissions.engine.generateAbility(permissions);
@@ -64,7 +68,11 @@ const authenticate = async (ctx) => {
64
68
 
65
69
  const publicPermissions = await getService('permission')
66
70
  .findPublicPermissions()
67
- .then(map(getService('permission').toContentAPIPermission));
71
+ .then((permissions) =>
72
+ map(permissions, (permission) =>
73
+ getService('permission').toContentAPIPermission(permission)
74
+ )
75
+ );
68
76
 
69
77
  if (publicPermissions.length === 0) {
70
78
  return { authenticated: false };
@@ -100,12 +108,8 @@ const verify = async (auth, config) => {
100
108
  throw new UnauthorizedError();
101
109
  }
102
110
 
103
- const isAllowed = pipe(
104
- // Make sure we're dealing with an array
105
- castArray,
106
- // Transform the scope array into an action array
107
- every((scope) => ability.can(scope))
108
- )(config.scope);
111
+ const scopes = Array.isArray(config.scope) ? config.scope : [config.scope];
112
+ const isAllowed = every(scopes, (scope) => ability.can(scope));
109
113
 
110
114
  if (!isAllowed) {
111
115
  throw new ForbiddenError();
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { curry } = require('lodash/fp');
3
+ const { curry } = require('lodash');
4
4
  const { traverseEntity, async } = require('@strapi/utils');
5
5
 
6
6
  const { removeUserRelationFromRoleEntities } = require('./visitors');