@strapi/plugin-users-permissions 4.0.0-next.6 → 4.0.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 (196) hide show
  1. package/admin/src/components/BoundRoute/getMethodColor.js +41 -0
  2. package/admin/src/components/BoundRoute/index.js +40 -24
  3. package/admin/src/components/FormModal/Input/index.js +121 -0
  4. package/admin/src/components/FormModal/index.js +123 -0
  5. package/admin/src/components/Permissions/PermissionRow/CheckboxWrapper.js +19 -26
  6. package/admin/src/components/Permissions/PermissionRow/SubCategory.js +118 -0
  7. package/admin/src/components/Permissions/PermissionRow/index.js +9 -48
  8. package/admin/src/components/Permissions/index.js +36 -24
  9. package/admin/src/components/Permissions/init.js +1 -6
  10. package/admin/src/components/Policies/index.js +46 -47
  11. package/admin/src/components/UsersPermissions/index.js +29 -26
  12. package/admin/src/components/UsersPermissions/init.js +1 -2
  13. package/admin/src/hooks/useFetchRole/index.js +17 -7
  14. package/admin/src/hooks/useForm/index.js +3 -29
  15. package/admin/src/hooks/useForm/reducer.js +2 -21
  16. package/admin/src/hooks/usePlugins/index.js +12 -21
  17. package/admin/src/hooks/usePlugins/reducer.js +0 -3
  18. package/admin/src/index.js +29 -34
  19. package/admin/src/pages/AdvancedSettings/index.js +210 -193
  20. package/admin/src/pages/AdvancedSettings/utils/api.js +13 -0
  21. package/admin/src/pages/AdvancedSettings/utils/layout.js +96 -0
  22. package/admin/src/pages/AdvancedSettings/utils/schema.js +22 -0
  23. package/admin/src/pages/EmailTemplates/components/EmailForm.js +173 -0
  24. package/admin/src/pages/EmailTemplates/components/EmailTable.js +116 -0
  25. package/admin/src/pages/EmailTemplates/index.js +125 -198
  26. package/admin/src/pages/EmailTemplates/utils/api.js +13 -0
  27. package/admin/src/pages/Providers/index.js +208 -216
  28. package/admin/src/pages/Providers/utils/api.js +21 -0
  29. package/admin/src/pages/Providers/utils/forms.js +168 -126
  30. package/admin/src/pages/Roles/CreatePage/index.js +155 -147
  31. package/admin/src/pages/Roles/EditPage/index.js +162 -134
  32. package/admin/src/pages/Roles/ListPage/components/TableBody.js +96 -0
  33. package/admin/src/pages/Roles/ListPage/index.js +176 -156
  34. package/admin/src/pages/Roles/ListPage/utils/api.js +28 -0
  35. package/admin/src/pages/Roles/index.js +14 -8
  36. package/admin/src/permissions.js +12 -14
  37. package/admin/src/translations/ar.json +0 -8
  38. package/admin/src/translations/cs.json +0 -8
  39. package/admin/src/translations/de.json +0 -8
  40. package/admin/src/translations/dk.json +0 -8
  41. package/admin/src/translations/en.json +33 -12
  42. package/admin/src/translations/es.json +0 -8
  43. package/admin/src/translations/fr.json +0 -8
  44. package/admin/src/translations/id.json +0 -8
  45. package/admin/src/translations/it.json +0 -8
  46. package/admin/src/translations/ja.json +0 -8
  47. package/admin/src/translations/ko.json +0 -8
  48. package/admin/src/translations/ms.json +0 -8
  49. package/admin/src/translations/nl.json +0 -8
  50. package/admin/src/translations/pl.json +0 -8
  51. package/admin/src/translations/pt-BR.json +0 -8
  52. package/admin/src/translations/pt.json +0 -8
  53. package/admin/src/translations/ru.json +0 -8
  54. package/admin/src/translations/sk.json +0 -8
  55. package/admin/src/translations/sv.json +0 -8
  56. package/admin/src/translations/th.json +0 -8
  57. package/admin/src/translations/tr.json +0 -8
  58. package/admin/src/translations/uk.json +0 -8
  59. package/admin/src/translations/vi.json +0 -8
  60. package/admin/src/translations/zh-Hans.json +5 -14
  61. package/admin/src/translations/zh.json +0 -8
  62. package/admin/src/utils/axiosInstance.js +36 -0
  63. package/admin/src/utils/formatPluginName.js +26 -0
  64. package/admin/src/utils/index.js +1 -0
  65. package/documentation/1.0.0/overrides/users-permissions-Role.json +6 -6
  66. package/documentation/1.0.0/overrides/users-permissions-User.json +7 -7
  67. package/package.json +30 -29
  68. package/{config/functions/bootstrap.js → server/bootstrap/index.js} +26 -33
  69. package/{config → server/bootstrap}/users-permissions-actions.js +0 -0
  70. package/server/config.js +23 -0
  71. package/server/content-types/index.js +11 -0
  72. package/server/content-types/permission/index.js +34 -0
  73. package/server/content-types/role/index.js +51 -0
  74. package/server/content-types/user/index.js +72 -0
  75. package/{models/User.config.js → server/content-types/user/schema-config.js} +0 -0
  76. package/server/controllers/auth.js +440 -0
  77. package/server/controllers/content-manager-user.js +183 -0
  78. package/server/controllers/index.js +17 -0
  79. package/server/controllers/permissions.js +26 -0
  80. package/server/controllers/role.js +77 -0
  81. package/server/controllers/settings.js +85 -0
  82. package/server/controllers/user.js +191 -0
  83. package/server/controllers/validation/auth.js +29 -0
  84. package/{controllers → server/controllers}/validation/email-template.js +0 -0
  85. package/server/controllers/validation/user.js +38 -0
  86. package/server/graphql/index.js +44 -0
  87. package/server/graphql/mutations/auth/email-confirmation.js +39 -0
  88. package/server/graphql/mutations/auth/forgot-password.js +38 -0
  89. package/server/graphql/mutations/auth/login.js +38 -0
  90. package/server/graphql/mutations/auth/register.js +39 -0
  91. package/server/graphql/mutations/auth/reset-password.js +41 -0
  92. package/server/graphql/mutations/crud/role/create-role.js +37 -0
  93. package/server/graphql/mutations/crud/role/delete-role.js +28 -0
  94. package/server/graphql/mutations/crud/role/update-role.js +38 -0
  95. package/server/graphql/mutations/crud/user/create-user.js +48 -0
  96. package/server/graphql/mutations/crud/user/delete-user.js +42 -0
  97. package/server/graphql/mutations/crud/user/update-user.js +49 -0
  98. package/server/graphql/mutations/index.js +42 -0
  99. package/server/graphql/queries/index.js +13 -0
  100. package/server/graphql/queries/me.js +17 -0
  101. package/server/graphql/resolvers-configs.js +37 -0
  102. package/server/graphql/types/create-role-payload.js +11 -0
  103. package/server/graphql/types/delete-role-payload.js +11 -0
  104. package/server/graphql/types/index.js +21 -0
  105. package/server/graphql/types/login-input.js +13 -0
  106. package/server/graphql/types/login-payload.js +12 -0
  107. package/server/graphql/types/me-role.js +14 -0
  108. package/server/graphql/types/me.js +16 -0
  109. package/server/graphql/types/password-payload.js +11 -0
  110. package/server/graphql/types/register-input.js +13 -0
  111. package/server/graphql/types/update-role-payload.js +11 -0
  112. package/server/graphql/utils.js +27 -0
  113. package/server/index.js +21 -0
  114. package/server/middlewares/index.js +7 -0
  115. package/{config/policies → server/middlewares}/rateLimit.js +4 -8
  116. package/server/register.js +11 -0
  117. package/server/routes/admin/index.js +10 -0
  118. package/server/routes/admin/permissions.js +20 -0
  119. package/server/routes/admin/role.js +79 -0
  120. package/server/routes/admin/settings.js +95 -0
  121. package/server/routes/content-api/auth.js +73 -0
  122. package/server/routes/content-api/index.js +11 -0
  123. package/server/routes/content-api/permissions.js +9 -0
  124. package/server/routes/content-api/role.js +29 -0
  125. package/server/routes/content-api/user.js +61 -0
  126. package/server/routes/index.js +6 -0
  127. package/server/services/index.js +15 -0
  128. package/server/services/jwt.js +55 -0
  129. package/server/services/providers.js +599 -0
  130. package/server/services/role.js +177 -0
  131. package/{services → server/services}/user.js +32 -35
  132. package/server/services/users-permissions.js +233 -0
  133. package/server/strategies/users-permissions.js +123 -0
  134. package/{utils → server/utils}/index.d.ts +6 -1
  135. package/server/utils/index.js +9 -0
  136. package/strapi-admin.js +3 -0
  137. package/strapi-server.js +3 -0
  138. package/admin/src/assets/images/logo.svg +0 -1
  139. package/admin/src/components/BaselineAlignement/index.js +0 -33
  140. package/admin/src/components/Bloc/index.js +0 -10
  141. package/admin/src/components/BoundRoute/Components.js +0 -78
  142. package/admin/src/components/ContainerFluid/index.js +0 -13
  143. package/admin/src/components/FormBloc/index.js +0 -61
  144. package/admin/src/components/IntlInput/index.js +0 -38
  145. package/admin/src/components/ListBaselineAlignment/index.js +0 -8
  146. package/admin/src/components/ListRow/Components.js +0 -74
  147. package/admin/src/components/ListRow/index.js +0 -35
  148. package/admin/src/components/ModalForm/Wrapper.js +0 -12
  149. package/admin/src/components/ModalForm/index.js +0 -59
  150. package/admin/src/components/Permissions/ListWrapper.js +0 -9
  151. package/admin/src/components/Permissions/PermissionRow/BaselineAlignment.js +0 -7
  152. package/admin/src/components/Permissions/PermissionRow/RowStyle.js +0 -28
  153. package/admin/src/components/Permissions/PermissionRow/SubCategory/ConditionsButtonWrapper.js +0 -13
  154. package/admin/src/components/Permissions/PermissionRow/SubCategory/PolicyWrapper.js +0 -8
  155. package/admin/src/components/Permissions/PermissionRow/SubCategory/SubCategoryWrapper.js +0 -26
  156. package/admin/src/components/Permissions/PermissionRow/SubCategory/index.js +0 -116
  157. package/admin/src/components/Policies/Components.js +0 -26
  158. package/admin/src/components/PrefixedIcon/index.js +0 -27
  159. package/admin/src/components/Roles/EmptyRole/BaselineAlignment.js +0 -7
  160. package/admin/src/components/Roles/EmptyRole/index.js +0 -27
  161. package/admin/src/components/Roles/RoleListWrapper/index.js +0 -17
  162. package/admin/src/components/Roles/RoleRow/RoleDescription.js +0 -9
  163. package/admin/src/components/Roles/RoleRow/index.js +0 -45
  164. package/admin/src/components/Roles/index.js +0 -3
  165. package/admin/src/components/SizedInput/index.js +0 -24
  166. package/admin/src/pages/AdvancedSettings/reducer.js +0 -65
  167. package/admin/src/pages/AdvancedSettings/utils/form.js +0 -52
  168. package/admin/src/pages/EmailTemplates/CustomTextInput.js +0 -105
  169. package/admin/src/pages/EmailTemplates/Wrapper.js +0 -36
  170. package/admin/src/pages/EmailTemplates/reducer.js +0 -58
  171. package/admin/src/pages/EmailTemplates/utils/forms.js +0 -81
  172. package/admin/src/pages/Roles/ListPage/BaselineAlignment.js +0 -8
  173. package/config/layout.js +0 -10
  174. package/config/policies/isAuthenticated.js +0 -9
  175. package/config/policies/permissions.js +0 -94
  176. package/config/request.json +0 -6
  177. package/config/routes.json +0 -381
  178. package/config/schema.graphql.js +0 -284
  179. package/config/security.json +0 -5
  180. package/controllers/auth.js +0 -596
  181. package/controllers/user/admin.js +0 -230
  182. package/controllers/user/api.js +0 -174
  183. package/controllers/user.js +0 -117
  184. package/controllers/users-permissions.js +0 -271
  185. package/middlewares/users-permissions/defaults.json +0 -5
  186. package/middlewares/users-permissions/index.js +0 -40
  187. package/models/Permission.js +0 -7
  188. package/models/Permission.settings.json +0 -45
  189. package/models/Role.js +0 -7
  190. package/models/Role.settings.json +0 -43
  191. package/models/User.js +0 -7
  192. package/models/User.settings.json +0 -63
  193. package/services/jwt.js +0 -65
  194. package/services/providers.js +0 -598
  195. package/services/users-permissions.js +0 -429
  196. package/utils/index.js +0 -11
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
- import { Flex, Padded, Text } from '@buffetjs/core';
3
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
- import { upperFirst } from 'lodash';
5
- import PropTypes from 'prop-types';
6
-
7
- const PrefixedIcon = ({ icon, name }) => {
8
- return (
9
- <Flex>
10
- <div>
11
- <FontAwesomeIcon icon={icon} />
12
- </div>
13
- <Padded left size="md">
14
- <Text fontWeight="semiBold" lineHeight="18px">
15
- {upperFirst(name)}
16
- </Text>
17
- </Padded>
18
- </Flex>
19
- );
20
- };
21
-
22
- PrefixedIcon.propTypes = {
23
- icon: PropTypes.array.isRequired,
24
- name: PropTypes.string.isRequired,
25
- };
26
-
27
- export default PrefixedIcon;
@@ -1,7 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- const BaselineAlignment = styled.div`
4
- padding-top: 2px;
5
- `;
6
-
7
- export default BaselineAlignment;
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
- import { Flex, Padded, Text } from '@buffetjs/core';
3
- import { useIntl } from 'react-intl';
4
-
5
- import BaselineAlignment from './BaselineAlignment';
6
-
7
- const EmptyRole = () => {
8
- const { formatMessage } = useIntl();
9
-
10
- return (
11
- <>
12
- <BaselineAlignment />
13
- <Padded top bottom size="md">
14
- <Flex justifyContent="center">
15
- <Text fontSize="lg" fontWeight="bold">
16
- {formatMessage({
17
- id: 'Roles.components.List.empty',
18
- defaultMessage: 'There is no role',
19
- })}
20
- </Text>
21
- </Flex>
22
- </Padded>
23
- </>
24
- );
25
- };
26
-
27
- export default EmptyRole;
@@ -1,17 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- const RoleListWrapper = styled.div`
4
- border-radius: 2px;
5
- box-shadow: 0 2px 4px #e3e9f3;
6
- background: white;
7
-
8
- > div,
9
- > div > div:last-of-type {
10
- box-shadow: none;
11
- border-radius: 2px;
12
- border-bottom-left-radius: 0;
13
- border-bottom-right-radius: 0;
14
- }
15
- `;
16
-
17
- export default RoleListWrapper;
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import { Text } from '@buffetjs/core';
4
-
5
- const RoleDescription = styled(props => <Text {...props} ellipsis />)`
6
- max-width: 25rem;
7
- `;
8
-
9
- export default RoleDescription;
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { CustomRow } from '@buffetjs/styles';
4
- import { IconLinks, Text } from '@buffetjs/core';
5
- import { useIntl } from 'react-intl';
6
-
7
- import RoleDescription from './RoleDescription';
8
-
9
- const RoleRow = ({ role, onClick, links }) => {
10
- const { formatMessage } = useIntl();
11
- const number = role.nb_users;
12
- const text = formatMessage(
13
- { id: `Roles.RoleRow.user-count.${number > 1 ? 'plural' : 'singular'}` },
14
- { number }
15
- );
16
-
17
- return (
18
- <CustomRow onClick={onClick}>
19
- <td>
20
- <Text fontWeight="semiBold">{role.name}</Text>
21
- </td>
22
- <td>
23
- <RoleDescription>{role.description}</RoleDescription>
24
- </td>
25
- <td>
26
- <Text>{text}</Text>
27
- </td>
28
- <td>
29
- <IconLinks links={links} />
30
- </td>
31
- </CustomRow>
32
- );
33
- };
34
-
35
- RoleRow.defaultProps = {
36
- onClick: null,
37
- };
38
-
39
- RoleRow.propTypes = {
40
- links: PropTypes.array.isRequired,
41
- onClick: PropTypes.func,
42
- role: PropTypes.object.isRequired,
43
- };
44
-
45
- export default RoleRow;
@@ -1,3 +0,0 @@
1
- export { default as RoleRow } from './RoleRow';
2
- export { default as RoleListWrapper } from './RoleListWrapper';
3
- export { default as EmptyRole } from './EmptyRole';
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { Col } from 'reactstrap';
3
- import PropTypes from 'prop-types';
4
- import IntlInput from '../IntlInput';
5
-
6
- const SizedInput = ({ size, ...rest }) => {
7
- return (
8
- <Col {...size}>
9
- <IntlInput {...rest} />
10
- </Col>
11
- );
12
- };
13
-
14
- SizedInput.defaultProps = {
15
- size: {
16
- xs: '12',
17
- },
18
- };
19
-
20
- SizedInput.propTypes = {
21
- size: PropTypes.object,
22
- };
23
-
24
- export default SizedInput;
@@ -1,65 +0,0 @@
1
- import produce from 'immer';
2
- import { set } from 'lodash';
3
-
4
- const initialState = {
5
- isLoading: true,
6
- isConfirmButtonLoading: false,
7
- initialData: {},
8
- modifiedData: {},
9
- roles: [],
10
- };
11
-
12
- const reducer = (state, action) =>
13
- // eslint-disable-next-line consistent-return
14
- produce(state, draftState => {
15
- switch (action.type) {
16
- case 'GET_DATA': {
17
- draftState.isLoading = true;
18
- draftState.isConfirmButtonLoading = false;
19
- draftState.initialData = {};
20
- draftState.modifiedData = {};
21
-
22
- break;
23
- }
24
-
25
- case 'GET_DATA_SUCCEEDED': {
26
- draftState.isLoading = false;
27
- draftState.initialData = action.data.settings;
28
- draftState.modifiedData = action.data.settings;
29
- draftState.roles = action.data.roles.map(role => ({ label: role.name, value: role.type }));
30
-
31
- break;
32
- }
33
- case 'GET_DATA_ERROR': {
34
- draftState.isLoading = true;
35
- break;
36
- }
37
- case 'ON_CHANGE': {
38
- set(draftState.modifiedData, action.keys.split('.'), action.value);
39
- break;
40
- }
41
- case 'ON_RESET': {
42
- draftState.modifiedData = state.initialData;
43
- break;
44
- }
45
- case 'ON_SUBMIT': {
46
- draftState.isConfirmButtonLoading = true;
47
- break;
48
- }
49
- case 'ON_SUBMIT_SUCCEEDED': {
50
- draftState.initialData = state.modifiedData;
51
- draftState.isConfirmButtonLoading = false;
52
- break;
53
- }
54
- case 'ON_SUBMIT_ERROR': {
55
- draftState.isConfirmButtonLoading = false;
56
- break;
57
- }
58
- default: {
59
- return draftState;
60
- }
61
- }
62
- });
63
-
64
- export default reducer;
65
- export { initialState };
@@ -1,52 +0,0 @@
1
- import { getTrad } from '../../../utils';
2
-
3
- const form = [
4
- {
5
- autoFocus: true,
6
- description: getTrad('EditForm.inputSelect.description.role'),
7
- label: getTrad('EditForm.inputSelect.label.role'),
8
- name: 'default_role',
9
- type: 'select',
10
- size: { xs: 6 },
11
- options: [],
12
- },
13
- {
14
- description: getTrad('EditForm.inputToggle.description.email'),
15
- label: getTrad('EditForm.inputToggle.label.email'),
16
- name: 'unique_email',
17
- type: 'bool',
18
- size: { xs: 12 },
19
- },
20
- {
21
- description: getTrad('EditForm.inputToggle.description.sign-up'),
22
- label: getTrad('EditForm.inputToggle.label.sign-up'),
23
- name: 'allow_register',
24
- type: 'bool',
25
- size: { xs: 12 },
26
- },
27
- {
28
- description: getTrad('EditForm.inputToggle.description.email-reset-password'),
29
- label: getTrad('EditForm.inputToggle.label.email-reset-password'),
30
- name: 'email_reset_password',
31
- type: 'text',
32
- size: { xs: 6 },
33
- placeholder: getTrad('EditForm.inputToggle.placeholder.email-reset-password'),
34
- },
35
- {
36
- description: getTrad('EditForm.inputToggle.description.email-confirmation'),
37
- label: getTrad('EditForm.inputToggle.label.email-confirmation'),
38
- name: 'email_confirmation',
39
- type: 'bool',
40
- size: { xs: 12 },
41
- },
42
- {
43
- description: getTrad('EditForm.inputToggle.description.email-confirmation-redirection'),
44
- label: getTrad('EditForm.inputToggle.label.email-confirmation-redirection'),
45
- name: 'email_confirmation_redirection',
46
- type: 'text',
47
- size: { xs: 6 },
48
- placeholder: getTrad('EditForm.inputToggle.placeholder.email-confirmation-redirection'),
49
- },
50
- ];
51
-
52
- export default form;
@@ -1,105 +0,0 @@
1
- /**
2
- *
3
- * The input is made so we can handle a custom descritption
4
- *
5
- */
6
-
7
- import React from 'react';
8
- import PropTypes from 'prop-types';
9
- import { Error, Label, InputText } from '@buffetjs/core';
10
- import { FormattedMessage } from 'react-intl';
11
- import { Description, ErrorMessage } from '@buffetjs/styles';
12
- import { getTrad } from '../../utils';
13
- import Wrapper from './Wrapper';
14
-
15
- const CustomTextInput = ({
16
- description,
17
- error: inputError,
18
- label,
19
- name,
20
- onChange,
21
- validations,
22
- value,
23
- ...rest
24
- }) => {
25
- const inputId = name;
26
- const descriptionId = `description-${inputId}`;
27
- const errorId = `error-${inputId}`;
28
-
29
- const link = (
30
- <a
31
- href="https://strapi.io/documentation/developer-docs/latest/development/plugins/users-permissions.html#templating-emails"
32
- target="_blank"
33
- rel="noopener noreferrer"
34
- >
35
- <FormattedMessage id="users-permissions.PopUpForm.Email.link.documentation" />
36
- </a>
37
- );
38
-
39
- const descriptionCompo = (
40
- <Description id={descriptionId}>
41
- <FormattedMessage
42
- id={getTrad('PopUpForm.Email.email_templates.inputDescription')}
43
- values={{ link }}
44
- />
45
- </Description>
46
- );
47
-
48
- return (
49
- <Error inputError={inputError} name={name} type="text" validations={validations}>
50
- {({ canCheck, onBlur, error, dispatch }) => (
51
- <Wrapper error={error}>
52
- <Label htmlFor={inputId}>{label}</Label>
53
- <InputText
54
- {...rest}
55
- name={name}
56
- id={inputId}
57
- aria-invalid={error ? 'true' : 'false'}
58
- onBlur={onBlur}
59
- onChange={e => {
60
- if (!canCheck) {
61
- dispatch({
62
- type: 'SET_CHECK',
63
- });
64
- }
65
-
66
- dispatch({
67
- type: 'SET_ERROR',
68
- error: null,
69
- });
70
- onChange(e);
71
- }}
72
- value={value}
73
- />
74
- {!error ? descriptionCompo : <ErrorMessage id={errorId}>{error}</ErrorMessage>}
75
- </Wrapper>
76
- )}
77
- </Error>
78
- );
79
- };
80
-
81
- CustomTextInput.defaultProps = {
82
- description: null,
83
- id: null,
84
- error: null,
85
- label: null,
86
- onBlur: null,
87
- onChange: () => {},
88
- validations: {},
89
- value: '',
90
- };
91
-
92
- CustomTextInput.propTypes = {
93
- description: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
94
- error: PropTypes.string,
95
- id: PropTypes.string,
96
- label: PropTypes.string,
97
- name: PropTypes.string.isRequired,
98
- onBlur: PropTypes.func,
99
- onChange: () => {},
100
-
101
- validations: PropTypes.object,
102
- value: PropTypes.any,
103
- };
104
-
105
- export default CustomTextInput;
@@ -1,36 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
- import { colors, sizes } from '@buffetjs/styles';
3
-
4
- /* eslint-disable indent */
5
- const Wrapper = styled.div`
6
- position: relative;
7
- padding-bottom: ${sizes.margin * 2.7}px;
8
- label {
9
- display: block;
10
- margin-bottom: 1rem;
11
- }
12
- > p {
13
- width: 100%;
14
- padding-top: 10px;
15
- font-size: 13px;
16
- line-height: normal;
17
- white-space: nowrap;
18
- overflow: hidden;
19
- text-overflow: ellipsis;
20
- margin-bottom: -8px;
21
- }
22
- input[type='checkbox'] {
23
- margin-bottom: 13px;
24
- }
25
- ${({ error }) =>
26
- !!error &&
27
- css`
28
- input,
29
- textarea,
30
- select {
31
- border-color: ${colors.darkOrange};
32
- }
33
- `}
34
- `;
35
-
36
- export default Wrapper;
@@ -1,58 +0,0 @@
1
- import produce from 'immer';
2
- import { set } from 'lodash';
3
-
4
- const initialState = {
5
- formErrors: {},
6
- isLoading: true,
7
- initialData: {},
8
- modifiedData: {},
9
- };
10
-
11
- const reducer = (state, action) =>
12
- // eslint-disable-next-line consistent-return
13
- produce(state, draftState => {
14
- switch (action.type) {
15
- case 'GET_DATA': {
16
- draftState.isLoading = true;
17
- draftState.initialData = {};
18
- draftState.modifiedData = {};
19
-
20
- break;
21
- }
22
-
23
- case 'GET_DATA_SUCCEEDED': {
24
- draftState.isLoading = false;
25
- draftState.initialData = action.data;
26
- draftState.modifiedData = action.data;
27
-
28
- break;
29
- }
30
- case 'GET_DATA_ERROR': {
31
- draftState.isLoading = true;
32
- break;
33
- }
34
- case 'ON_CHANGE': {
35
- set(draftState, ['modifiedData', ...action.keys.split('.')], action.value);
36
- break;
37
- }
38
- case 'ON_SUBMIT_SUCCEEDED': {
39
- draftState.initialData = state.modifiedData;
40
- break;
41
- }
42
- case 'RESET_FORM': {
43
- draftState.modifiedData = state.initialData;
44
- draftState.formErrors = {};
45
- break;
46
- }
47
- case 'SET_ERRORS': {
48
- draftState.formErrors = action.errors;
49
- break;
50
- }
51
- default: {
52
- return draftState;
53
- }
54
- }
55
- });
56
-
57
- export default reducer;
58
- export { initialState };
@@ -1,81 +0,0 @@
1
- import React from 'react';
2
- import { FormattedMessage } from 'react-intl';
3
- import { getTrad } from '../../../utils';
4
- import CustomTextInput from '../CustomTextInput';
5
-
6
- const forms = [
7
- {
8
- autoFocus: true,
9
- label: getTrad('PopUpForm.Email.options.from.name.label'),
10
- name: 'options.from.name',
11
- type: 'text',
12
- placeholder: getTrad('PopUpForm.Email.options.from.name.placeholder'),
13
- size: { xs: 6 },
14
- validations: {
15
- required: true,
16
- },
17
- },
18
- {
19
- autoFocus: false,
20
- label: getTrad('PopUpForm.Email.options.from.email.label'),
21
- name: 'options.from.email',
22
- type: 'email',
23
- placeholder: getTrad('PopUpForm.Email.options.from.email.placeholder'),
24
- size: { xs: 6 },
25
- validations: {
26
- required: true,
27
- },
28
- },
29
- {
30
- autoFocus: false,
31
- label: getTrad('PopUpForm.Email.options.response_email.label'),
32
- name: 'options.response_email',
33
- type: 'email',
34
- placeholder: getTrad('PopUpForm.Email.options.response_email.placeholder'),
35
- size: { xs: 6 },
36
- validations: {
37
- required: true,
38
- },
39
- },
40
- {
41
- autoFocus: false,
42
- label: getTrad('PopUpForm.Email.options.object.label'),
43
- name: 'options.object',
44
- type: 'customText',
45
- placeholder: getTrad('PopUpForm.Email.options.object.placeholder'),
46
- customInputs: { customText: CustomTextInput },
47
- descriptione: () => (
48
- <FormattedMessage
49
- id={getTrad('PopUpForm.Email.email_templates.inputDescription')}
50
- values={{
51
- link: (
52
- <a
53
- href="https://strapi.io/documentation/developer-docs/latest/development/plugins/users-permissions.html#templating-emails"
54
- target="_blank"
55
- rel="noopener noreferrer"
56
- >
57
- <FormattedMessage id={getTrad('PopUpForm.Email.link.documentation')} />
58
- </a>
59
- ),
60
- }}
61
- />
62
- ),
63
- size: { xs: 6 },
64
- validations: {
65
- required: true,
66
- },
67
- },
68
- {
69
- autoFocus: false,
70
- label: getTrad('PopUpForm.Email.options.message.label'),
71
- name: 'options.message',
72
- type: 'textarea',
73
- style: { height: '15.6rem' },
74
- size: { xs: 12 },
75
- validations: {
76
- required: true,
77
- },
78
- },
79
- ];
80
-
81
- export default forms;
@@ -1,8 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- // TODO : Temporary baseline alignment
4
- const BaselineAlignment = styled.div`
5
- padding-top: 3px;
6
- `;
7
-
8
- export default BaselineAlignment;
package/config/layout.js DELETED
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- user: {
5
- actions: {
6
- create: 'User.create', // Use the User plugin's controller.
7
- update: 'User.update',
8
- },
9
- },
10
- };
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = async (ctx, next) => {
4
- if (!ctx.state.user) {
5
- return ctx.unauthorized();
6
- }
7
-
8
- await next();
9
- };
@@ -1,94 +0,0 @@
1
- 'use strict';
2
-
3
- const _ = require('lodash');
4
- const { getService } = require('../../utils');
5
-
6
- module.exports = async (ctx, next) => {
7
- let role;
8
-
9
- if (ctx.state.user) {
10
- // request is already authenticated in a different way
11
- return next();
12
- }
13
-
14
- if (ctx.request && ctx.request.header && ctx.request.header.authorization) {
15
- try {
16
- const { id } = await getService('jwt').getToken(ctx);
17
-
18
- if (id === undefined) {
19
- throw new Error('Invalid token: Token did not contain required fields');
20
- }
21
-
22
- // fetch authenticated user
23
- ctx.state.user = await getService('user').fetchAuthenticatedUser(id);
24
- } catch (err) {
25
- return handleErrors(ctx, err, 'unauthorized');
26
- }
27
-
28
- if (!ctx.state.user) {
29
- return handleErrors(ctx, 'User Not Found', 'unauthorized');
30
- }
31
-
32
- role = ctx.state.user.role;
33
-
34
- if (role.type === 'root') {
35
- return await next();
36
- }
37
-
38
- const store = await strapi.store({
39
- environment: '',
40
- type: 'plugin',
41
- name: 'users-permissions',
42
- });
43
-
44
- if (
45
- _.get(await store.get({ key: 'advanced' }), 'email_confirmation') &&
46
- !ctx.state.user.confirmed
47
- ) {
48
- return handleErrors(ctx, 'Your account email is not confirmed.', 'unauthorized');
49
- }
50
-
51
- if (ctx.state.user.blocked) {
52
- return handleErrors(
53
- ctx,
54
- 'Your account has been blocked by the administrator.',
55
- 'unauthorized'
56
- );
57
- }
58
- }
59
-
60
- // Retrieve `public` role.
61
- if (!role) {
62
- role = await strapi
63
- .query('plugins::users-permissions.role')
64
- .findOne({ where: { type: 'public' } });
65
- }
66
-
67
- const route = ctx.request.route;
68
-
69
- const permission = await strapi.query('plugins::users-permissions.permission').findOne({
70
- where: {
71
- role: { id: role.id },
72
- type: route.plugin || 'application',
73
- controller: route.controller,
74
- action: route.action,
75
- enabled: true,
76
- },
77
- });
78
-
79
- if (!permission) {
80
- return handleErrors(ctx, undefined, 'forbidden');
81
- }
82
-
83
- // Execute the policies.
84
- if (permission.policy) {
85
- return await strapi.plugins['users-permissions'].config.policies[permission.policy](ctx, next);
86
- }
87
-
88
- // Execute the action.
89
- await next();
90
- };
91
-
92
- const handleErrors = (ctx, err = undefined, type) => {
93
- throw strapi.errors[type](err);
94
- };