@strapi/plugin-users-permissions 4.6.0 → 4.6.2
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/BoundRoute/index.js +1 -3
- package/admin/src/components/FormModal/Input/index.js +1 -2
- package/admin/src/components/FormModal/index.js +7 -5
- package/admin/src/components/Permissions/PermissionRow/CheckboxWrapper.js +1 -1
- package/admin/src/components/Permissions/PermissionRow/SubCategory.js +2 -6
- package/admin/src/components/Permissions/PermissionRow/index.js +1 -1
- package/admin/src/components/Permissions/index.js +1 -3
- package/admin/src/components/Policies/index.js +1 -3
- package/admin/src/components/UsersPermissions/index.js +1 -3
- package/admin/src/hooks/useFetchRole/index.js +3 -3
- package/admin/src/hooks/usePlugins/index.js +5 -3
- package/admin/src/pages/AdvancedSettings/index.js +15 -10
- package/admin/src/pages/AdvancedSettings/utils/api.js +7 -3
- package/admin/src/pages/EmailTemplates/components/EmailForm.js +7 -5
- package/admin/src/pages/EmailTemplates/components/EmailTable.js +14 -9
- package/admin/src/pages/EmailTemplates/index.js +1 -3
- package/admin/src/pages/EmailTemplates/utils/api.js +7 -3
- package/admin/src/pages/Providers/index.js +17 -8
- package/admin/src/pages/Providers/utils/api.js +7 -3
- package/admin/src/pages/Roles/CreatePage/index.js +17 -12
- package/admin/src/pages/Roles/EditPage/index.js +17 -13
- package/admin/src/pages/Roles/ListPage/components/TableBody.js +2 -6
- package/admin/src/pages/Roles/ListPage/index.js +16 -8
- package/admin/src/pages/Roles/ListPage/utils/api.js +6 -3
- package/admin/src/utils/index.js +0 -1
- package/package.json +7 -8
- package/server/bootstrap/grant-config.js +8 -0
- package/server/services/providers-registry.js +30 -0
- package/server/services/providers.js +1 -1
- package/admin/src/utils/axiosInstance.js +0 -38
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import { Stack } from '@strapi/design-system
|
|
4
|
-
import { Box } from '@strapi/design-system/Box';
|
|
5
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
3
|
+
import { Stack, Box, Typography } from '@strapi/design-system';
|
|
6
4
|
import map from 'lodash/map';
|
|
7
5
|
import tail from 'lodash/tail';
|
|
8
6
|
import { useIntl } from 'react-intl';
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { useIntl } from 'react-intl';
|
|
9
|
-
import { ToggleInput } from '@strapi/design-system
|
|
10
|
-
import { TextInput } from '@strapi/design-system/TextInput';
|
|
9
|
+
import { ToggleInput, TextInput } from '@strapi/design-system';
|
|
11
10
|
import PropTypes from 'prop-types';
|
|
12
11
|
|
|
13
12
|
const Input = ({
|
|
@@ -6,16 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { useIntl } from 'react-intl';
|
|
9
|
-
import { Button } from '@strapi/design-system/Button';
|
|
10
|
-
import { Stack } from '@strapi/design-system/Stack';
|
|
11
|
-
import { Breadcrumbs, Crumb } from '@strapi/design-system/Breadcrumbs';
|
|
12
|
-
import { Grid, GridItem } from '@strapi/design-system/Grid';
|
|
13
9
|
import {
|
|
10
|
+
Button,
|
|
11
|
+
Stack,
|
|
12
|
+
Breadcrumbs,
|
|
13
|
+
Crumb,
|
|
14
|
+
Grid,
|
|
15
|
+
GridItem,
|
|
14
16
|
ModalLayout,
|
|
15
17
|
ModalHeader,
|
|
16
18
|
ModalFooter,
|
|
17
19
|
ModalBody,
|
|
18
|
-
} from '@strapi/design-system
|
|
20
|
+
} from '@strapi/design-system';
|
|
19
21
|
import PropTypes from 'prop-types';
|
|
20
22
|
import { Formik } from 'formik';
|
|
21
23
|
import { Form } from '@strapi/helper-plugin';
|
|
@@ -2,12 +2,8 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
2
2
|
import { get } from 'lodash';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { Box } from '@strapi/design-system
|
|
6
|
-
import {
|
|
7
|
-
import { Flex } from '@strapi/design-system/Flex';
|
|
8
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
9
|
-
import { Grid, GridItem } from '@strapi/design-system/Grid';
|
|
10
|
-
import CogIcon from '@strapi/icons/Cog';
|
|
5
|
+
import { Box, Checkbox, Flex, Typography, Grid, GridItem } from '@strapi/design-system';
|
|
6
|
+
import { Cog as CogIcon } from '@strapi/icons';
|
|
11
7
|
import { useIntl } from 'react-intl';
|
|
12
8
|
import CheckboxWrapper from './CheckboxWrapper';
|
|
13
9
|
import { useUsersPermissions } from '../../../contexts/UsersPermissionsContext';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import sortBy from 'lodash/sortBy';
|
|
4
|
-
import { Box } from '@strapi/design-system
|
|
4
|
+
import { Box } from '@strapi/design-system';
|
|
5
5
|
import SubCategory from './SubCategory';
|
|
6
6
|
|
|
7
7
|
const PermissionRow = ({ name, permissions }) => {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React, { useReducer } from 'react';
|
|
2
|
-
import { Accordion, AccordionToggle, AccordionContent } from '@strapi/design-system
|
|
2
|
+
import { Accordion, AccordionToggle, AccordionContent, Box, Stack } from '@strapi/design-system';
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
|
-
import { Box } from '@strapi/design-system/Box';
|
|
5
|
-
import { Stack } from '@strapi/design-system/Stack';
|
|
6
4
|
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
|
|
7
5
|
import formatPluginName from '../../utils/formatPluginName';
|
|
8
6
|
import PermissionRow from './PermissionRow';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
-
import { Typography } from '@strapi/design-system
|
|
4
|
-
import { Stack } from '@strapi/design-system/Stack';
|
|
5
|
-
import { GridItem } from '@strapi/design-system/Grid';
|
|
3
|
+
import { Typography, Stack, GridItem } from '@strapi/design-system';
|
|
6
4
|
import { get, isEmpty, without } from 'lodash';
|
|
7
5
|
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
|
|
8
6
|
import BoundRoute from '../BoundRoute';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React, { memo, useReducer, forwardRef, useImperativeHandle } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { Typography } from '@strapi/design-system
|
|
4
|
-
import { Stack } from '@strapi/design-system/Stack';
|
|
5
|
-
import { Grid, GridItem } from '@strapi/design-system/Grid';
|
|
3
|
+
import { Typography, Stack, Grid, GridItem } from '@strapi/design-system';
|
|
6
4
|
import { useIntl } from 'react-intl';
|
|
7
5
|
import getTrad from '../../utils/getTrad';
|
|
8
6
|
import Policies from '../Policies';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useCallback, useReducer, useEffect, useRef } from 'react';
|
|
2
|
-
import { useNotification } from '@strapi/helper-plugin';
|
|
2
|
+
import { useNotification, useFetchClient } from '@strapi/helper-plugin';
|
|
3
3
|
import reducer, { initialState } from './reducer';
|
|
4
|
-
import axiosInstance from '../../utils/axiosInstance';
|
|
5
4
|
import pluginId from '../../pluginId';
|
|
6
5
|
|
|
7
6
|
const useFetchRole = (id) => {
|
|
8
7
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
9
8
|
const toggleNotification = useNotification();
|
|
10
9
|
const isMounted = useRef(null);
|
|
10
|
+
const { get } = useFetchClient();
|
|
11
11
|
|
|
12
12
|
useEffect(() => {
|
|
13
13
|
isMounted.current = true;
|
|
@@ -29,7 +29,7 @@ const useFetchRole = (id) => {
|
|
|
29
29
|
try {
|
|
30
30
|
const {
|
|
31
31
|
data: { role },
|
|
32
|
-
} = await
|
|
32
|
+
} = await get(`/${pluginId}/roles/${roleId}`);
|
|
33
33
|
|
|
34
34
|
// Prevent updating state on an unmounted component
|
|
35
35
|
if (isMounted.current) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { useCallback, useEffect, useReducer } from 'react';
|
|
2
|
-
import { useNotification } from '@strapi/helper-plugin';
|
|
2
|
+
import { useNotification, useFetchClient } from '@strapi/helper-plugin';
|
|
3
3
|
import { get } from 'lodash';
|
|
4
4
|
import init from './init';
|
|
5
5
|
import pluginId from '../../pluginId';
|
|
6
6
|
import { cleanPermissions } from '../../utils';
|
|
7
|
-
import axiosInstance from '../../utils/axiosInstance';
|
|
8
7
|
import reducer, { initialState } from './reducer';
|
|
9
8
|
|
|
10
9
|
const usePlugins = (shouldFetchData = true) => {
|
|
@@ -12,6 +11,7 @@ const usePlugins = (shouldFetchData = true) => {
|
|
|
12
11
|
const [{ permissions, routes, isLoading }, dispatch] = useReducer(reducer, initialState, () =>
|
|
13
12
|
init(initialState, shouldFetchData)
|
|
14
13
|
);
|
|
14
|
+
const fetchClient = useFetchClient();
|
|
15
15
|
|
|
16
16
|
const fetchPlugins = useCallback(async () => {
|
|
17
17
|
try {
|
|
@@ -21,7 +21,7 @@ const usePlugins = (shouldFetchData = true) => {
|
|
|
21
21
|
|
|
22
22
|
const [{ permissions }, { routes }] = await Promise.all(
|
|
23
23
|
[`/${pluginId}/permissions`, `/${pluginId}/routes`].map(async (endpoint) => {
|
|
24
|
-
const res = await
|
|
24
|
+
const res = await fetchClient.get(endpoint);
|
|
25
25
|
|
|
26
26
|
return res.data;
|
|
27
27
|
})
|
|
@@ -46,6 +46,8 @@ const usePlugins = (shouldFetchData = true) => {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
51
|
}, [toggleNotification]);
|
|
50
52
|
|
|
51
53
|
useEffect(() => {
|
|
@@ -13,16 +13,21 @@ import {
|
|
|
13
13
|
useOverlayBlocker,
|
|
14
14
|
useRBAC,
|
|
15
15
|
} from '@strapi/helper-plugin';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
import {
|
|
17
|
+
useNotifyAT,
|
|
18
|
+
Main,
|
|
19
|
+
HeaderLayout,
|
|
20
|
+
ContentLayout,
|
|
21
|
+
Button,
|
|
22
|
+
Box,
|
|
23
|
+
Stack,
|
|
24
|
+
Select,
|
|
25
|
+
Option,
|
|
26
|
+
Typography,
|
|
27
|
+
Grid,
|
|
28
|
+
GridItem,
|
|
29
|
+
} from '@strapi/design-system';
|
|
30
|
+
import { Check } from '@strapi/icons';
|
|
26
31
|
import pluginPermissions from '../../permissions';
|
|
27
32
|
import { getTrad } from '../../utils';
|
|
28
33
|
import layout from './utils/layout';
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getFetchClient } from '@strapi/helper-plugin';
|
|
2
|
+
import { getRequestURL } from '../../../utils';
|
|
2
3
|
|
|
3
4
|
const fetchData = async () => {
|
|
4
|
-
const {
|
|
5
|
+
const { get } = getFetchClient();
|
|
6
|
+
const { data } = await get(getRequestURL('advanced'));
|
|
5
7
|
|
|
6
8
|
return data;
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
const putAdvancedSettings = (body) => {
|
|
10
|
-
|
|
12
|
+
const { put } = getFetchClient();
|
|
13
|
+
|
|
14
|
+
return put(getRequestURL('advanced'), body);
|
|
11
15
|
};
|
|
12
16
|
|
|
13
17
|
export { fetchData, putAdvancedSettings };
|
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
ModalHeader,
|
|
9
9
|
ModalFooter,
|
|
10
10
|
ModalBody,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
Grid,
|
|
12
|
+
GridItem,
|
|
13
|
+
Button,
|
|
14
|
+
Breadcrumbs,
|
|
15
|
+
Crumb,
|
|
16
|
+
Textarea,
|
|
17
|
+
} from '@strapi/design-system';
|
|
16
18
|
import { getTrad } from '../../../utils';
|
|
17
19
|
import schema from '../utils/schema';
|
|
18
20
|
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import {
|
|
5
|
+
Table,
|
|
6
|
+
Thead,
|
|
7
|
+
Tbody,
|
|
8
|
+
Tr,
|
|
9
|
+
Td,
|
|
10
|
+
Th,
|
|
11
|
+
Typography,
|
|
12
|
+
IconButton,
|
|
13
|
+
Icon,
|
|
14
|
+
VisuallyHidden,
|
|
15
|
+
} from '@strapi/design-system';
|
|
16
|
+
import { Pencil, Refresh, Check } from '@strapi/icons';
|
|
11
17
|
import { onRowClick, stopPropagation } from '@strapi/helper-plugin';
|
|
12
|
-
import Check from '@strapi/icons/Check';
|
|
13
18
|
import { getTrad } from '../../../utils';
|
|
14
19
|
|
|
15
20
|
const EmailTable = ({ canUpdate, onEditClick }) => {
|
|
@@ -49,7 +54,7 @@ const EmailTable = ({ canUpdate, onEditClick }) => {
|
|
|
49
54
|
<Tr {...onRowClick({ fn: () => onEditClick('reset_password') })}>
|
|
50
55
|
<Td>
|
|
51
56
|
<Icon>
|
|
52
|
-
<
|
|
57
|
+
<Refresh
|
|
53
58
|
aria-label={formatMessage({
|
|
54
59
|
id: 'global.reset-password',
|
|
55
60
|
defaultMessage: 'Reset password',
|
|
@@ -11,9 +11,7 @@ import {
|
|
|
11
11
|
useFocusWhenNavigate,
|
|
12
12
|
LoadingIndicatorPage,
|
|
13
13
|
} from '@strapi/helper-plugin';
|
|
14
|
-
import { useNotifyAT } from '@strapi/design-system
|
|
15
|
-
import { Main } from '@strapi/design-system/Main';
|
|
16
|
-
import { ContentLayout, HeaderLayout } from '@strapi/design-system/Layout';
|
|
14
|
+
import { useNotifyAT, Main, ContentLayout, HeaderLayout } from '@strapi/design-system';
|
|
17
15
|
import pluginPermissions from '../../permissions';
|
|
18
16
|
import { getTrad } from '../../utils';
|
|
19
17
|
import { fetchData, putEmailTemplate } from './utils/api';
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getFetchClient } from '@strapi/helper-plugin';
|
|
2
|
+
import { getRequestURL } from '../../../utils';
|
|
2
3
|
|
|
3
4
|
const fetchData = async () => {
|
|
4
|
-
const {
|
|
5
|
+
const { get } = getFetchClient();
|
|
6
|
+
const { data } = await get(getRequestURL('email-templates'));
|
|
5
7
|
|
|
6
8
|
return data;
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
const putEmailTemplate = (body) => {
|
|
10
|
-
|
|
12
|
+
const { put } = getFetchClient();
|
|
13
|
+
|
|
14
|
+
return put(getRequestURL('email-templates'), body);
|
|
11
15
|
};
|
|
12
16
|
|
|
13
17
|
export { fetchData, putEmailTemplate };
|
|
@@ -14,14 +14,23 @@ import {
|
|
|
14
14
|
} from '@strapi/helper-plugin';
|
|
15
15
|
import has from 'lodash/has';
|
|
16
16
|
import upperFirst from 'lodash/upperFirst';
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
import {
|
|
18
|
+
HeaderLayout,
|
|
19
|
+
Layout,
|
|
20
|
+
ContentLayout,
|
|
21
|
+
Main,
|
|
22
|
+
useNotifyAT,
|
|
23
|
+
Table,
|
|
24
|
+
Thead,
|
|
25
|
+
Tr,
|
|
26
|
+
Th,
|
|
27
|
+
Tbody,
|
|
28
|
+
Td,
|
|
29
|
+
Typography,
|
|
30
|
+
IconButton,
|
|
31
|
+
VisuallyHidden,
|
|
32
|
+
} from '@strapi/design-system';
|
|
33
|
+
import { Pencil } from '@strapi/icons';
|
|
25
34
|
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
|
26
35
|
import forms from './utils/forms';
|
|
27
36
|
import { fetchData, putProvider } from './utils/api';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getFetchClient } from '@strapi/helper-plugin';
|
|
2
|
+
import { getRequestURL } from '../../../utils';
|
|
2
3
|
|
|
3
4
|
// eslint-disable-next-line import/prefer-default-export
|
|
4
5
|
export const fetchData = async (toggleNotification) => {
|
|
5
6
|
try {
|
|
6
|
-
const {
|
|
7
|
+
const { get } = getFetchClient();
|
|
8
|
+
const { data } = await get(getRequestURL('providers'));
|
|
7
9
|
|
|
8
10
|
return data;
|
|
9
11
|
} catch (err) {
|
|
@@ -17,5 +19,7 @@ export const fetchData = async (toggleNotification) => {
|
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
export const putProvider = (body) => {
|
|
20
|
-
|
|
22
|
+
const { put } = getFetchClient();
|
|
23
|
+
|
|
24
|
+
return put(getRequestURL('providers'), body);
|
|
21
25
|
};
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import React, { useState, useRef } from 'react';
|
|
2
2
|
import { useHistory } from 'react-router-dom';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import {
|
|
4
|
+
ContentLayout,
|
|
5
|
+
HeaderLayout,
|
|
6
|
+
Main,
|
|
7
|
+
Button,
|
|
8
|
+
Stack,
|
|
9
|
+
Box,
|
|
10
|
+
TextInput,
|
|
11
|
+
Textarea,
|
|
12
|
+
Typography,
|
|
13
|
+
GridItem,
|
|
14
|
+
Grid,
|
|
15
|
+
} from '@strapi/design-system';
|
|
16
|
+
import { Check } from '@strapi/icons';
|
|
13
17
|
import { Formik } from 'formik';
|
|
14
18
|
import { useIntl } from 'react-intl';
|
|
15
19
|
import {
|
|
16
20
|
useOverlayBlocker,
|
|
17
21
|
SettingsPageTitle,
|
|
22
|
+
useFetchClient,
|
|
18
23
|
useTracking,
|
|
19
24
|
Form,
|
|
20
25
|
useNotification,
|
|
@@ -24,7 +29,6 @@ import getTrad from '../../../utils/getTrad';
|
|
|
24
29
|
import pluginId from '../../../pluginId';
|
|
25
30
|
import { usePlugins } from '../../../hooks';
|
|
26
31
|
import schema from './utils/schema';
|
|
27
|
-
import axiosInstance from '../../../utils/axiosInstance';
|
|
28
32
|
|
|
29
33
|
const EditPage = () => {
|
|
30
34
|
const { formatMessage } = useIntl();
|
|
@@ -35,6 +39,7 @@ const EditPage = () => {
|
|
|
35
39
|
const { isLoading: isLoadingPlugins, permissions, routes } = usePlugins();
|
|
36
40
|
const { trackUsage } = useTracking();
|
|
37
41
|
const permissionsRef = useRef();
|
|
42
|
+
const { post } = useFetchClient();
|
|
38
43
|
|
|
39
44
|
const handleCreateRoleSubmit = async (data) => {
|
|
40
45
|
// Set loading state
|
|
@@ -43,7 +48,7 @@ const EditPage = () => {
|
|
|
43
48
|
try {
|
|
44
49
|
const permissions = permissionsRef.current.getPermissions();
|
|
45
50
|
// Update role in Strapi
|
|
46
|
-
await
|
|
51
|
+
await post(`/${pluginId}/roles`, { ...data, ...permissions, users: [] });
|
|
47
52
|
// Notify success
|
|
48
53
|
trackUsage('didCreateRole');
|
|
49
54
|
toggleNotification({
|
|
@@ -3,6 +3,7 @@ import { Formik } from 'formik';
|
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
4
|
import { useRouteMatch } from 'react-router-dom';
|
|
5
5
|
import {
|
|
6
|
+
useFetchClient,
|
|
6
7
|
useOverlayBlocker,
|
|
7
8
|
SettingsPageTitle,
|
|
8
9
|
LoadingIndicatorPage,
|
|
@@ -10,23 +11,25 @@ import {
|
|
|
10
11
|
useNotification,
|
|
11
12
|
Link,
|
|
12
13
|
} from '@strapi/helper-plugin';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
import {
|
|
15
|
+
ContentLayout,
|
|
16
|
+
HeaderLayout,
|
|
17
|
+
Main,
|
|
18
|
+
Button,
|
|
19
|
+
Stack,
|
|
20
|
+
Box,
|
|
21
|
+
TextInput,
|
|
22
|
+
Textarea,
|
|
23
|
+
Typography,
|
|
24
|
+
GridItem,
|
|
25
|
+
Grid,
|
|
26
|
+
} from '@strapi/design-system';
|
|
27
|
+
import { ArrowLeft, Check } from '@strapi/icons';
|
|
24
28
|
import UsersPermissions from '../../../components/UsersPermissions';
|
|
25
29
|
import getTrad from '../../../utils/getTrad';
|
|
26
30
|
import pluginId from '../../../pluginId';
|
|
27
31
|
import { usePlugins, useFetchRole } from '../../../hooks';
|
|
28
32
|
import schema from './utils/schema';
|
|
29
|
-
import axiosInstance from '../../../utils/axiosInstance';
|
|
30
33
|
|
|
31
34
|
const EditPage = () => {
|
|
32
35
|
const { formatMessage } = useIntl();
|
|
@@ -39,6 +42,7 @@ const EditPage = () => {
|
|
|
39
42
|
const { isLoading: isLoadingPlugins, routes } = usePlugins();
|
|
40
43
|
const { role, onSubmitSucceeded, isLoading: isLoadingRole } = useFetchRole(id);
|
|
41
44
|
const permissionsRef = useRef();
|
|
45
|
+
const { put } = useFetchClient();
|
|
42
46
|
|
|
43
47
|
const handleEditRoleSubmit = async (data) => {
|
|
44
48
|
// Set loading state
|
|
@@ -47,7 +51,7 @@ const EditPage = () => {
|
|
|
47
51
|
try {
|
|
48
52
|
const permissions = permissionsRef.current.getPermissions();
|
|
49
53
|
// Update role in Strapi
|
|
50
|
-
await
|
|
54
|
+
await put(`/${pluginId}/roles/${id}`, { ...data, ...permissions, users: [] });
|
|
51
55
|
// Notify success
|
|
52
56
|
onSubmitSucceeded({ name: data.name, description: data.description });
|
|
53
57
|
toggleNotification({
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { IconButton } from '@strapi/design-system
|
|
4
|
-
import {
|
|
5
|
-
import { Flex } from '@strapi/design-system/Flex';
|
|
6
|
-
import { Tbody, Tr, Td } from '@strapi/design-system/Table';
|
|
7
|
-
import Pencil from '@strapi/icons/Pencil';
|
|
8
|
-
import Trash from '@strapi/icons/Trash';
|
|
3
|
+
import { IconButton, Typography, Flex, Tbody, Tr, Td } from '@strapi/design-system';
|
|
4
|
+
import { Pencil, Trash } from '@strapi/icons';
|
|
9
5
|
import { CheckPermissions, onRowClick, stopPropagation } from '@strapi/helper-plugin';
|
|
10
6
|
import { useIntl } from 'react-intl';
|
|
11
7
|
import { useHistory } from 'react-router-dom';
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import React, { useMemo, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
HeaderLayout,
|
|
5
|
+
Layout,
|
|
6
|
+
ContentLayout,
|
|
7
|
+
ActionLayout,
|
|
8
|
+
Main,
|
|
9
|
+
Table,
|
|
10
|
+
Tr,
|
|
11
|
+
Thead,
|
|
12
|
+
Th,
|
|
13
|
+
Typography,
|
|
14
|
+
useNotifyAT,
|
|
15
|
+
VisuallyHidden,
|
|
16
|
+
} from '@strapi/design-system';
|
|
17
|
+
import { Plus } from '@strapi/icons';
|
|
10
18
|
import {
|
|
11
19
|
useTracking,
|
|
12
20
|
SettingsPageTitle,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getFetchClient } from '@strapi/helper-plugin';
|
|
2
|
+
import { getRequestURL } from '../../../../utils';
|
|
2
3
|
|
|
3
4
|
export const fetchData = async (toggleNotification, notifyStatus) => {
|
|
4
5
|
try {
|
|
5
|
-
const {
|
|
6
|
+
const { get } = getFetchClient();
|
|
7
|
+
const { data } = await get(getRequestURL('roles'));
|
|
6
8
|
notifyStatus('The roles have loaded successfully');
|
|
7
9
|
|
|
8
10
|
return data;
|
|
@@ -18,7 +20,8 @@ export const fetchData = async (toggleNotification, notifyStatus) => {
|
|
|
18
20
|
|
|
19
21
|
export const deleteData = async (id, toggleNotification) => {
|
|
20
22
|
try {
|
|
21
|
-
|
|
23
|
+
const { del } = getFetchClient();
|
|
24
|
+
await del(`${getRequestURL('roles')}/${id}`);
|
|
22
25
|
} catch (error) {
|
|
23
26
|
toggleNotification({
|
|
24
27
|
type: 'warning',
|
package/admin/src/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-users-permissions",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.2",
|
|
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.6.
|
|
31
|
-
"@strapi/utils": "4.6.
|
|
30
|
+
"@strapi/helper-plugin": "4.6.2",
|
|
31
|
+
"@strapi/utils": "4.6.2",
|
|
32
32
|
"bcryptjs": "2.4.3",
|
|
33
33
|
"grant-koa": "5.4.8",
|
|
34
34
|
"jsonwebtoken": "9.0.0",
|
|
@@ -39,11 +39,10 @@
|
|
|
39
39
|
"purest": "4.0.2",
|
|
40
40
|
"react": "^17.0.2",
|
|
41
41
|
"react-dom": "^17.0.2",
|
|
42
|
-
"react-intl": "
|
|
43
|
-
"react-redux": "
|
|
42
|
+
"react-intl": "6.2.8",
|
|
43
|
+
"react-redux": "8.0.5",
|
|
44
44
|
"react-router": "^5.2.0",
|
|
45
45
|
"react-router-dom": "5.3.4",
|
|
46
|
-
"request": "^2.83.0",
|
|
47
46
|
"url-join": "4.0.1"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
@@ -51,7 +50,7 @@
|
|
|
51
50
|
"@testing-library/react": "12.1.4",
|
|
52
51
|
"@testing-library/react-hooks": "8.0.1",
|
|
53
52
|
"@testing-library/user-event": "14.4.3",
|
|
54
|
-
"msw": "0.
|
|
53
|
+
"msw": "1.0.1",
|
|
55
54
|
"react-test-renderer": "^17.0.2"
|
|
56
55
|
},
|
|
57
56
|
"engines": {
|
|
@@ -65,5 +64,5 @@
|
|
|
65
64
|
"required": true,
|
|
66
65
|
"kind": "plugin"
|
|
67
66
|
},
|
|
68
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "bae505f44c3a779905f6b8dbc0c497e24d9eabfb"
|
|
69
68
|
}
|
|
@@ -120,4 +120,12 @@ module.exports = (baseURL) => ({
|
|
|
120
120
|
scope: ['openid email'], // scopes should be space delimited
|
|
121
121
|
subdomain: 'my.subdomain.com/cas',
|
|
122
122
|
},
|
|
123
|
+
patreon: {
|
|
124
|
+
enabled: false,
|
|
125
|
+
icon: '',
|
|
126
|
+
key: '',
|
|
127
|
+
secret: '',
|
|
128
|
+
callback: `${baseURL}/patreon/callback`,
|
|
129
|
+
scope: ['identity', 'identity[email]'],
|
|
130
|
+
},
|
|
123
131
|
});
|
|
@@ -48,6 +48,7 @@ const getCognitoPayload = async ({ idToken, jwksUrl, purest }) => {
|
|
|
48
48
|
const getInitialProviders = ({ purest }) => ({
|
|
49
49
|
async discord({ accessToken }) {
|
|
50
50
|
const discord = purest({ provider: 'discord' });
|
|
51
|
+
|
|
51
52
|
return discord
|
|
52
53
|
.get('users/@me')
|
|
53
54
|
.auth(accessToken)
|
|
@@ -301,6 +302,35 @@ const getInitialProviders = ({ purest }) => ({
|
|
|
301
302
|
};
|
|
302
303
|
});
|
|
303
304
|
},
|
|
305
|
+
async patreon({ accessToken }) {
|
|
306
|
+
const patreon = purest({
|
|
307
|
+
provider: 'patreon',
|
|
308
|
+
config: {
|
|
309
|
+
patreon: {
|
|
310
|
+
default: {
|
|
311
|
+
origin: 'https://www.patreon.com',
|
|
312
|
+
path: 'api/oauth2/{path}',
|
|
313
|
+
headers: {
|
|
314
|
+
authorization: 'Bearer {auth}',
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
return patreon
|
|
322
|
+
.get('v2/identity')
|
|
323
|
+
.auth(accessToken)
|
|
324
|
+
.qs(new URLSearchParams({ 'fields[user]': 'full_name,email' }).toString())
|
|
325
|
+
.request()
|
|
326
|
+
.then(({ body }) => {
|
|
327
|
+
const patreonData = body.data.attributes;
|
|
328
|
+
return {
|
|
329
|
+
username: patreonData.full_name,
|
|
330
|
+
email: patreonData.email,
|
|
331
|
+
};
|
|
332
|
+
});
|
|
333
|
+
},
|
|
304
334
|
});
|
|
305
335
|
|
|
306
336
|
module.exports = () => {
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { auth, wrapAxiosInstance } from '@strapi/helper-plugin';
|
|
3
|
-
|
|
4
|
-
const instance = axios.create({
|
|
5
|
-
baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
instance.interceptors.request.use(
|
|
9
|
-
async (config) => {
|
|
10
|
-
config.headers = {
|
|
11
|
-
Authorization: `Bearer ${auth.getToken()}`,
|
|
12
|
-
Accept: 'application/json',
|
|
13
|
-
'Content-Type': 'application/json',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return config;
|
|
17
|
-
},
|
|
18
|
-
(error) => {
|
|
19
|
-
Promise.reject(error);
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
instance.interceptors.response.use(
|
|
24
|
-
(response) => response,
|
|
25
|
-
(error) => {
|
|
26
|
-
// whatever you want to do with the error
|
|
27
|
-
if (error.response?.status === 401) {
|
|
28
|
-
auth.clearAppStorage();
|
|
29
|
-
window.location.reload();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const wrapper = wrapAxiosInstance(instance);
|
|
37
|
-
|
|
38
|
-
export default wrapper;
|