@strapi/plugin-users-permissions 4.1.8 → 4.1.10
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/admin/src/pages/Roles/EditPage/index.js +11 -11
- package/package.json +4 -4
- package/server/controllers/role.js +4 -4
- package/server/controllers/settings.js +1 -1
- package/server/controllers/user.js +6 -4
- package/server/register.js +2 -0
- package/server/routes/admin/role.js +2 -2
- package/server/routes/content-api/role.js +2 -2
- package/server/services/role.js +2 -2
- package/server/services/user.js +4 -4
- package/server/utils/index.js +3 -0
- package/server/utils/sanitize/index.js +9 -0
- package/server/utils/sanitize/sanitizers.js +19 -0
- package/server/utils/sanitize/visitors/index.js +5 -0
- package/server/utils/sanitize/visitors/remove-user-relation-from-role-entities.js +11 -0
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import React, { useState, useRef } from 'react';
|
|
2
|
+
import { Formik } from 'formik';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import { useRouteMatch } from 'react-router-dom';
|
|
5
|
+
import {
|
|
6
|
+
useOverlayBlocker,
|
|
7
|
+
SettingsPageTitle,
|
|
8
|
+
LoadingIndicatorPage,
|
|
9
|
+
Form,
|
|
10
|
+
useNotification,
|
|
11
|
+
Link,
|
|
12
|
+
} from '@strapi/helper-plugin';
|
|
2
13
|
import { ContentLayout, HeaderLayout } from '@strapi/design-system/Layout';
|
|
3
14
|
import { Main } from '@strapi/design-system/Main';
|
|
4
15
|
import { Button } from '@strapi/design-system/Button';
|
|
@@ -9,18 +20,7 @@ import { Textarea } from '@strapi/design-system/Textarea';
|
|
|
9
20
|
import { Typography } from '@strapi/design-system/Typography';
|
|
10
21
|
import ArrowLeft from '@strapi/icons/ArrowLeft';
|
|
11
22
|
import Check from '@strapi/icons/Check';
|
|
12
|
-
import { Link } from '@strapi/design-system/Link';
|
|
13
23
|
import { GridItem, Grid } from '@strapi/design-system/Grid';
|
|
14
|
-
import { Formik } from 'formik';
|
|
15
|
-
import { useIntl } from 'react-intl';
|
|
16
|
-
import { useRouteMatch } from 'react-router-dom';
|
|
17
|
-
import {
|
|
18
|
-
useOverlayBlocker,
|
|
19
|
-
SettingsPageTitle,
|
|
20
|
-
LoadingIndicatorPage,
|
|
21
|
-
Form,
|
|
22
|
-
useNotification,
|
|
23
|
-
} from '@strapi/helper-plugin';
|
|
24
24
|
import UsersPermissions from '../../../components/UsersPermissions';
|
|
25
25
|
import getTrad from '../../../utils/getTrad';
|
|
26
26
|
import pluginId from '../../../pluginId';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-users-permissions",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.10",
|
|
4
4
|
"description": "Protect your API with a full-authentication process based on JWT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"test:front:watch:ce": "cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@strapi/helper-plugin": "4.1.
|
|
31
|
-
"@strapi/utils": "4.1.
|
|
30
|
+
"@strapi/helper-plugin": "4.1.10",
|
|
31
|
+
"@strapi/utils": "4.1.10",
|
|
32
32
|
"bcryptjs": "2.4.3",
|
|
33
33
|
"grant-koa": "5.4.8",
|
|
34
34
|
"jsonwebtoken": "^8.1.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"required": true,
|
|
60
60
|
"kind": "plugin"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "06abcda86ab96fc560b3ff5e3d72c4d5c1c5d42c"
|
|
63
63
|
}
|
|
@@ -21,10 +21,10 @@ module.exports = {
|
|
|
21
21
|
ctx.send({ ok: true });
|
|
22
22
|
},
|
|
23
23
|
|
|
24
|
-
async
|
|
24
|
+
async findOne(ctx) {
|
|
25
25
|
const { id } = ctx.params;
|
|
26
26
|
|
|
27
|
-
const role = await getService('role').
|
|
27
|
+
const role = await getService('role').findOne(id);
|
|
28
28
|
|
|
29
29
|
if (!role) {
|
|
30
30
|
return ctx.notFound();
|
|
@@ -33,8 +33,8 @@ module.exports = {
|
|
|
33
33
|
ctx.send({ role });
|
|
34
34
|
},
|
|
35
35
|
|
|
36
|
-
async
|
|
37
|
-
const roles = await getService('role').
|
|
36
|
+
async find(ctx) {
|
|
37
|
+
const roles = await getService('role').find();
|
|
38
38
|
|
|
39
39
|
ctx.send({ roles });
|
|
40
40
|
},
|
|
@@ -90,7 +90,7 @@ module.exports = {
|
|
|
90
90
|
const { id } = ctx.params;
|
|
91
91
|
const { email, username, password } = ctx.request.body;
|
|
92
92
|
|
|
93
|
-
const user = await getService('user').fetch(
|
|
93
|
+
const user = await getService('user').fetch(id);
|
|
94
94
|
|
|
95
95
|
await validateUpdateUserBody(ctx.request.body);
|
|
96
96
|
|
|
@@ -133,8 +133,8 @@ module.exports = {
|
|
|
133
133
|
* Retrieve user records.
|
|
134
134
|
* @return {Object|Array}
|
|
135
135
|
*/
|
|
136
|
-
async find(ctx
|
|
137
|
-
const users = await getService('user').fetchAll(ctx.query
|
|
136
|
+
async find(ctx) {
|
|
137
|
+
const users = await getService('user').fetchAll(ctx.query);
|
|
138
138
|
|
|
139
139
|
ctx.body = await Promise.all(users.map(user => sanitizeOutput(user, ctx)));
|
|
140
140
|
},
|
|
@@ -145,7 +145,9 @@ module.exports = {
|
|
|
145
145
|
*/
|
|
146
146
|
async findOne(ctx) {
|
|
147
147
|
const { id } = ctx.params;
|
|
148
|
-
|
|
148
|
+
const { query } = ctx;
|
|
149
|
+
|
|
150
|
+
let data = await getService('user').fetch(id, query);
|
|
149
151
|
|
|
150
152
|
if (data) {
|
|
151
153
|
data = await sanitizeOutput(data, ctx);
|
package/server/register.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const authStrategy = require('./strategies/users-permissions');
|
|
4
|
+
const sanitizers = require('./utils/sanitize/sanitizers');
|
|
4
5
|
|
|
5
6
|
module.exports = ({ strapi }) => {
|
|
6
7
|
strapi.container.get('auth').register('content-api', authStrategy);
|
|
8
|
+
strapi.sanitizers.add('content-api.output', sanitizers.defaultSanitizeOutput);
|
|
7
9
|
|
|
8
10
|
if (strapi.plugin('graphql')) {
|
|
9
11
|
require('./graphql')({ strapi });
|
|
@@ -4,7 +4,7 @@ module.exports = [
|
|
|
4
4
|
{
|
|
5
5
|
method: 'GET',
|
|
6
6
|
path: '/roles/:id',
|
|
7
|
-
handler: 'role.
|
|
7
|
+
handler: 'role.findOne',
|
|
8
8
|
config: {
|
|
9
9
|
policies: [
|
|
10
10
|
{
|
|
@@ -19,7 +19,7 @@ module.exports = [
|
|
|
19
19
|
{
|
|
20
20
|
method: 'GET',
|
|
21
21
|
path: '/roles',
|
|
22
|
-
handler: 'role.
|
|
22
|
+
handler: 'role.find',
|
|
23
23
|
config: {
|
|
24
24
|
policies: [
|
|
25
25
|
{
|
package/server/services/role.js
CHANGED
|
@@ -41,7 +41,7 @@ module.exports = ({ strapi }) => ({
|
|
|
41
41
|
await Promise.all(createPromises);
|
|
42
42
|
},
|
|
43
43
|
|
|
44
|
-
async
|
|
44
|
+
async findOne(roleID) {
|
|
45
45
|
const role = await strapi
|
|
46
46
|
.query('plugin::users-permissions.role')
|
|
47
47
|
.findOne({ where: { id: roleID }, populate: ['permissions'] });
|
|
@@ -68,7 +68,7 @@ module.exports = ({ strapi }) => ({
|
|
|
68
68
|
};
|
|
69
69
|
},
|
|
70
70
|
|
|
71
|
-
async
|
|
71
|
+
async find() {
|
|
72
72
|
const roles = await strapi.query('plugin::users-permissions.role').findMany({ sort: ['name'] });
|
|
73
73
|
|
|
74
74
|
for (const role of roles) {
|
package/server/services/user.js
CHANGED
|
@@ -58,8 +58,8 @@ module.exports = ({ strapi }) => ({
|
|
|
58
58
|
* Promise to fetch a/an user.
|
|
59
59
|
* @return {Promise}
|
|
60
60
|
*/
|
|
61
|
-
fetch(
|
|
62
|
-
return strapi.
|
|
61
|
+
fetch(id, params) {
|
|
62
|
+
return strapi.entityService.findOne('plugin::users-permissions.user', id, params);
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -76,8 +76,8 @@ module.exports = ({ strapi }) => ({
|
|
|
76
76
|
* Promise to fetch all users.
|
|
77
77
|
* @return {Promise}
|
|
78
78
|
*/
|
|
79
|
-
fetchAll(params
|
|
80
|
-
return strapi.
|
|
79
|
+
fetchAll(params) {
|
|
80
|
+
return strapi.entityService.findMany('plugin::users-permissions.user', params);
|
|
81
81
|
},
|
|
82
82
|
|
|
83
83
|
/**
|
package/server/utils/index.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { curry } = require('lodash/fp');
|
|
4
|
+
const { traverseEntity, pipeAsync } = require('@strapi/utils');
|
|
5
|
+
|
|
6
|
+
const { removeUserRelationFromRoleEntities } = require('./visitors');
|
|
7
|
+
|
|
8
|
+
const sanitizeUserRelationFromRoleEntities = curry((schema, entity) => {
|
|
9
|
+
return traverseEntity(removeUserRelationFromRoleEntities, { schema }, entity);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const defaultSanitizeOutput = curry((schema, entity) => {
|
|
13
|
+
return pipeAsync(sanitizeUserRelationFromRoleEntities(schema))(entity);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
sanitizeUserRelationFromRoleEntities,
|
|
18
|
+
defaultSanitizeOutput,
|
|
19
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = ({ schema, key, attribute }, { remove }) => {
|
|
4
|
+
if (
|
|
5
|
+
attribute.type === 'relation' &&
|
|
6
|
+
attribute.target === 'plugin::users-permissions.user' &&
|
|
7
|
+
schema.uid === 'plugin::users-permissions.role'
|
|
8
|
+
) {
|
|
9
|
+
remove(key);
|
|
10
|
+
}
|
|
11
|
+
};
|