@strapi/plugin-users-permissions 4.0.0-beta.14 → 4.0.0-beta.18
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/components/Permissions/index.js +8 -7
- package/admin/src/components/Policies/index.js +5 -2
- package/admin/src/components/UsersPermissions/index.js +5 -8
- package/admin/src/pages/Roles/ListPage/index.js +2 -0
- package/package.json +5 -4
- package/server/content-types/permission/index.js +3 -0
- package/server/content-types/role/index.js +3 -0
- package/server/services/providers.js +4 -3
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useReducer } from 'react';
|
|
2
2
|
import { Accordion, AccordionToggle, AccordionContent } from '@strapi/design-system/Accordion';
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
4
|
import { Box } from '@strapi/design-system/Box';
|
|
5
|
+
import { Stack } from '@strapi/design-system/Stack';
|
|
5
6
|
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
|
|
6
7
|
import formatPluginName from '../../utils/formatPluginName';
|
|
7
8
|
import PermissionRow from './PermissionRow';
|
|
@@ -15,20 +16,20 @@ const Permissions = () => {
|
|
|
15
16
|
init(state, modifiedData)
|
|
16
17
|
);
|
|
17
18
|
|
|
18
|
-
const handleToggle =
|
|
19
|
+
const handleToggle = index =>
|
|
19
20
|
dispatch({
|
|
20
21
|
type: 'TOGGLE_COLLAPSE',
|
|
21
22
|
index,
|
|
22
23
|
});
|
|
23
|
-
}, []);
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
|
|
26
|
+
<Stack size={1}>
|
|
27
27
|
{collapses.map((collapse, index) => (
|
|
28
28
|
<Accordion
|
|
29
29
|
expanded={collapse.isOpen}
|
|
30
30
|
toggle={() => handleToggle(index)}
|
|
31
31
|
key={collapse.name}
|
|
32
|
+
variant={index % 2 === 0 ? 'secondary' : undefined}
|
|
32
33
|
>
|
|
33
34
|
<AccordionToggle
|
|
34
35
|
title={formatPluginName(collapse.name)}
|
|
@@ -42,14 +43,14 @@ const Permissions = () => {
|
|
|
42
43
|
variant={index % 2 ? 'primary' : 'secondary'}
|
|
43
44
|
/>
|
|
44
45
|
<AccordionContent>
|
|
45
|
-
<Box
|
|
46
|
+
<Box>
|
|
46
47
|
<PermissionRow permissions={modifiedData[collapse.name]} name={collapse.name} />
|
|
47
48
|
</Box>
|
|
48
49
|
</AccordionContent>
|
|
49
50
|
</Accordion>
|
|
50
51
|
))}
|
|
51
|
-
|
|
52
|
+
</Stack>
|
|
52
53
|
);
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
export default
|
|
56
|
+
export default Permissions;
|
|
@@ -3,18 +3,21 @@ import { useIntl } from 'react-intl';
|
|
|
3
3
|
import { Typography } from '@strapi/design-system/Typography';
|
|
4
4
|
import { Stack } from '@strapi/design-system/Stack';
|
|
5
5
|
import { GridItem } from '@strapi/design-system/Grid';
|
|
6
|
-
import { get, isEmpty,
|
|
6
|
+
import { get, isEmpty, without } from 'lodash';
|
|
7
7
|
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
|
|
8
8
|
import BoundRoute from '../BoundRoute';
|
|
9
9
|
|
|
10
10
|
const Policies = () => {
|
|
11
11
|
const { formatMessage } = useIntl();
|
|
12
12
|
const { selectedAction, routes } = useUsersPermissions();
|
|
13
|
+
|
|
13
14
|
const path = without(selectedAction.split('.'), 'controllers');
|
|
14
15
|
const controllerRoutes = get(routes, path[0]);
|
|
16
|
+
const pathResolved = path.slice(1).join('.');
|
|
17
|
+
|
|
15
18
|
const displayedRoutes = isEmpty(controllerRoutes)
|
|
16
19
|
? []
|
|
17
|
-
: controllerRoutes.filter(o =>
|
|
20
|
+
: controllerRoutes.filter(o => o.handler.endsWith(pathResolved));
|
|
18
21
|
|
|
19
22
|
return (
|
|
20
23
|
<GridItem
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo, useReducer,
|
|
1
|
+
import React, { memo, useReducer, forwardRef, useImperativeHandle } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Typography } from '@strapi/design-system/Typography';
|
|
4
4
|
import { Stack } from '@strapi/design-system/Stack';
|
|
@@ -31,28 +31,25 @@ const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
|
|
|
31
31
|
},
|
|
32
32
|
}));
|
|
33
33
|
|
|
34
|
-
const handleChange =
|
|
34
|
+
const handleChange = ({ target: { name, value } }) =>
|
|
35
35
|
dispatch({
|
|
36
36
|
type: 'ON_CHANGE',
|
|
37
37
|
keys: name.split('.'),
|
|
38
38
|
value: value === 'empty__string_value' ? '' : value,
|
|
39
39
|
});
|
|
40
|
-
}, []);
|
|
41
40
|
|
|
42
|
-
const handleChangeSelectAll =
|
|
41
|
+
const handleChangeSelectAll = ({ target: { name, value } }) =>
|
|
43
42
|
dispatch({
|
|
44
43
|
type: 'ON_CHANGE_SELECT_ALL',
|
|
45
44
|
keys: name.split('.'),
|
|
46
45
|
value,
|
|
47
46
|
});
|
|
48
|
-
}, []);
|
|
49
47
|
|
|
50
|
-
const handleSelectedAction =
|
|
48
|
+
const handleSelectedAction = actionToSelect =>
|
|
51
49
|
dispatch({
|
|
52
50
|
type: 'SELECT_ACTION',
|
|
53
51
|
actionToSelect,
|
|
54
52
|
});
|
|
55
|
-
}, []);
|
|
56
53
|
|
|
57
54
|
const providerValue = {
|
|
58
55
|
...state,
|
|
@@ -65,7 +62,7 @@ const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
|
|
|
65
62
|
<UsersPermissionsProvider value={providerValue}>
|
|
66
63
|
<Grid gap={0} shadow="filterShadow" hasRadius background="neutral0">
|
|
67
64
|
<GridItem col={7} paddingTop={6} paddingBottom={6} paddingLeft={7} paddingRight={7}>
|
|
68
|
-
<Stack size={
|
|
65
|
+
<Stack size={6}>
|
|
69
66
|
<Stack size={2}>
|
|
70
67
|
<Typography variant="delta" as="h2">
|
|
71
68
|
{formatMessage({
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
NoPermissions,
|
|
17
17
|
LoadingIndicatorPage,
|
|
18
18
|
SearchURLQuery,
|
|
19
|
+
useFocusWhenNavigate,
|
|
19
20
|
useQueryParams,
|
|
20
21
|
EmptyStateLayout,
|
|
21
22
|
ConfirmDialog,
|
|
@@ -42,6 +43,7 @@ const RoleListPage = () => {
|
|
|
42
43
|
const [showConfirmDelete, setShowConfirmDelete] = useState(false);
|
|
43
44
|
const [isConfirmButtonLoading, setIsConfirmButtonLoading] = useState(false);
|
|
44
45
|
const [roleToDelete, setRoleToDelete] = useState();
|
|
46
|
+
useFocusWhenNavigate();
|
|
45
47
|
|
|
46
48
|
const queryClient = useQueryClient();
|
|
47
49
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-users-permissions",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.18",
|
|
4
4
|
"description": "Protect your API with a full-authentication process based on JWT",
|
|
5
5
|
"strapi": {
|
|
6
6
|
"displayName": "Roles & Permissions",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@purest/providers": "^1.0.2",
|
|
17
|
-
"@strapi/helper-plugin": "4.0.0-beta.
|
|
18
|
-
"@strapi/utils": "4.0.0-beta.
|
|
17
|
+
"@strapi/helper-plugin": "4.0.0-beta.18",
|
|
18
|
+
"@strapi/utils": "4.0.0-beta.18",
|
|
19
19
|
"bcryptjs": "2.4.3",
|
|
20
20
|
"grant-koa": "5.4.8",
|
|
21
21
|
"jsonwebtoken": "^8.1.0",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"react-router-dom": "5.2.0",
|
|
31
31
|
"redux-saga": "^0.16.0",
|
|
32
32
|
"request": "^2.83.0",
|
|
33
|
+
"url-join": "4.0.1",
|
|
33
34
|
"uuid": "^3.1.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
@@ -56,5 +57,5 @@
|
|
|
56
57
|
"npm": ">=6.0.0"
|
|
57
58
|
},
|
|
58
59
|
"license": "SEE LICENSE IN LICENSE",
|
|
59
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "3e9e3f13cb85822e6d92b0e448ae0b94d440dac1"
|
|
60
61
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// Public node modules.
|
|
8
8
|
const _ = require('lodash');
|
|
9
9
|
const jwt = require('jsonwebtoken');
|
|
10
|
+
const urlJoin = require('url-join');
|
|
10
11
|
|
|
11
12
|
const { getAbsoluteServerUrl } = require('@strapi/utils');
|
|
12
13
|
|
|
@@ -167,7 +168,7 @@ module.exports = ({ strapi }) => {
|
|
|
167
168
|
return callback(null, {
|
|
168
169
|
username: userbody.login,
|
|
169
170
|
email: Array.isArray(emailsbody)
|
|
170
|
-
? emailsbody.find(email => email.primary === true).email
|
|
171
|
+
? emailsbody.find((email) => email.primary === true).email
|
|
171
172
|
: null,
|
|
172
173
|
});
|
|
173
174
|
});
|
|
@@ -550,7 +551,7 @@ module.exports = ({ strapi }) => {
|
|
|
550
551
|
}
|
|
551
552
|
|
|
552
553
|
if (
|
|
553
|
-
!_.isEmpty(_.find(users, user => user.provider !== provider)) &&
|
|
554
|
+
!_.isEmpty(_.find(users, (user) => user.provider !== provider)) &&
|
|
554
555
|
advanced.unique_email
|
|
555
556
|
) {
|
|
556
557
|
return resolve([
|
|
@@ -588,7 +589,7 @@ module.exports = ({ strapi }) => {
|
|
|
588
589
|
|
|
589
590
|
const buildRedirectUri = (provider = '') => {
|
|
590
591
|
const apiPrefix = strapi.config.get('api.rest.prefix');
|
|
591
|
-
return
|
|
592
|
+
return urlJoin(getAbsoluteServerUrl(strapi.config), apiPrefix, 'connect', provider, 'callback');
|
|
592
593
|
};
|
|
593
594
|
|
|
594
595
|
return {
|