@strapi/plugin-users-permissions 4.3.4 → 4.3.7
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/getMethodColor.js +1 -1
- package/admin/src/components/BoundRoute/index.js +1 -1
- package/admin/src/components/FormModal/Input/index.js +1 -1
- package/admin/src/components/FormModal/index.js +7 -9
- package/admin/src/components/Permissions/PermissionRow/CheckboxWrapper.js +3 -3
- package/admin/src/components/Permissions/PermissionRow/SubCategory.js +10 -14
- package/admin/src/components/Permissions/PermissionRow/index.js +1 -1
- package/admin/src/components/Permissions/index.js +2 -2
- package/admin/src/components/Permissions/init.js +1 -1
- package/admin/src/components/Permissions/reducer.js +1 -1
- package/admin/src/components/Policies/index.js +1 -1
- package/admin/src/components/UsersPermissions/index.js +5 -5
- package/admin/src/components/UsersPermissions/reducer.js +1 -1
- package/admin/src/hooks/useFetchRole/index.js +3 -3
- package/admin/src/hooks/useFetchRole/reducer.js +1 -1
- package/admin/src/hooks/useForm/index.js +1 -1
- package/admin/src/hooks/useForm/reducer.js +1 -1
- package/admin/src/hooks/usePlugins/index.js +1 -1
- package/admin/src/hooks/usePlugins/reducer.js +1 -1
- package/admin/src/hooks/useRolesList/reducer.js +1 -1
- package/admin/src/index.js +5 -5
- package/admin/src/pages/AdvancedSettings/index.js +12 -11
- package/admin/src/pages/AdvancedSettings/utils/api.js +1 -1
- package/admin/src/pages/AdvancedSettings/utils/schema.js +2 -4
- package/admin/src/pages/EmailTemplates/index.js +8 -8
- package/admin/src/pages/EmailTemplates/utils/api.js +1 -1
- package/admin/src/pages/EmailTemplates/utils/schema.js +1 -4
- package/admin/src/pages/Providers/index.js +22 -22
- package/admin/src/pages/Providers/reducer.js +1 -1
- package/admin/src/pages/Providers/utils/api.js +2 -2
- package/admin/src/pages/Providers/utils/createProvidersArray.js +1 -1
- package/admin/src/pages/Roles/CreatePage/index.js +1 -1
- package/admin/src/pages/Roles/EditPage/index.js +1 -1
- package/admin/src/pages/Roles/ListPage/components/TableBody.js +5 -4
- package/admin/src/pages/Roles/ListPage/index.js +3 -3
- package/admin/src/utils/axiosInstance.js +4 -4
- package/admin/src/utils/cleanPermissions.js +1 -1
- package/admin/src/utils/formatPolicies.js +1 -1
- package/admin/src/utils/getRequestURL.js +1 -1
- package/admin/src/utils/getTrad.js +1 -1
- package/documentation/content-api.yaml +54 -31
- package/jest.config.front.js +1 -1
- package/package.json +12 -7
- package/server/bootstrap/grant-config.js +1 -1
- package/server/bootstrap/index.js +39 -39
- package/server/controllers/auth.js +2 -5
- package/server/controllers/content-manager-user.js +4 -12
- package/server/controllers/settings.js +1 -1
- package/server/controllers/user.js +2 -2
- package/server/controllers/validation/auth.js +3 -12
- package/server/controllers/validation/email-template.js +3 -2
- package/server/controllers/validation/user.js +4 -16
- package/server/graphql/mutations/auth/change-password.js +1 -4
- package/server/graphql/mutations/auth/forgot-password.js +1 -4
- package/server/graphql/mutations/auth/login.js +1 -4
- package/server/graphql/mutations/auth/register.js +1 -4
- package/server/graphql/mutations/auth/reset-password.js +1 -4
- package/server/graphql/mutations/crud/role/create-role.js +1 -4
- package/server/graphql/mutations/crud/role/delete-role.js +1 -4
- package/server/graphql/mutations/crud/role/update-role.js +1 -4
- package/server/graphql/mutations/crud/user/create-user.js +1 -4
- package/server/graphql/mutations/crud/user/delete-user.js +1 -4
- package/server/graphql/mutations/crud/user/update-user.js +1 -4
- package/server/graphql/mutations/index.js +1 -1
- package/server/graphql/types/index.js +1 -1
- package/server/middlewares/rateLimit.js +22 -25
- package/server/register.js +2 -4
- package/server/services/jwt.js +11 -9
- package/server/services/providers-registry.js +33 -42
- package/server/services/providers.js +6 -6
- package/server/services/role.js +7 -7
- package/server/services/user.js +1 -1
- package/server/services/users-permissions.js +12 -12
- package/server/strategies/users-permissions.js +3 -3
- package/server/utils/index.js +1 -1
|
@@ -53,26 +53,26 @@ export const ProvidersPage = () => {
|
|
|
53
53
|
allowedActions: { canUpdate },
|
|
54
54
|
} = useRBAC(updatePermissions);
|
|
55
55
|
|
|
56
|
-
const {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
);
|
|
56
|
+
const {
|
|
57
|
+
isLoading: isLoadingForData,
|
|
58
|
+
data: modifiedData,
|
|
59
|
+
isFetching,
|
|
60
|
+
} = useQuery('get-providers', () => fetchData(toggleNotification), {
|
|
61
|
+
onSuccess() {
|
|
62
|
+
notifyStatus(
|
|
63
|
+
formatMessage({
|
|
64
|
+
id: getTrad('Providers.data.loaded'),
|
|
65
|
+
defaultMessage: 'Providers have been loaded',
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
initialData: {},
|
|
70
|
+
});
|
|
71
71
|
|
|
72
72
|
const isLoading = isLoadingForData || isFetching;
|
|
73
73
|
|
|
74
74
|
const submitMutation = useMutation(putProvider, {
|
|
75
|
-
|
|
75
|
+
async onSuccess() {
|
|
76
76
|
await queryClient.invalidateQueries('get-providers');
|
|
77
77
|
toggleNotification({
|
|
78
78
|
type: 'info',
|
|
@@ -84,7 +84,7 @@ export const ProvidersPage = () => {
|
|
|
84
84
|
handleToggleModal();
|
|
85
85
|
unlockApp();
|
|
86
86
|
},
|
|
87
|
-
onError
|
|
87
|
+
onError() {
|
|
88
88
|
toggleNotification({
|
|
89
89
|
type: 'warning',
|
|
90
90
|
message: { id: 'notification.error' },
|
|
@@ -104,7 +104,7 @@ export const ProvidersPage = () => {
|
|
|
104
104
|
return false;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
const providerToEdit = providers.find(obj => obj.name === providerToEditName);
|
|
107
|
+
const providerToEdit = providers.find((obj) => obj.name === providerToEditName);
|
|
108
108
|
|
|
109
109
|
return has(providerToEdit, 'subdomain');
|
|
110
110
|
}, [providers, providerToEditName]);
|
|
@@ -127,17 +127,17 @@ export const ProvidersPage = () => {
|
|
|
127
127
|
}, [providerToEditName, isProviderWithSubdomain]);
|
|
128
128
|
|
|
129
129
|
const handleToggleModal = () => {
|
|
130
|
-
setIsOpen(prev => !prev);
|
|
130
|
+
setIsOpen((prev) => !prev);
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
const handleClickEdit = provider => {
|
|
133
|
+
const handleClickEdit = (provider) => {
|
|
134
134
|
if (canUpdate) {
|
|
135
135
|
setProviderToEditName(provider.name);
|
|
136
136
|
handleToggleModal();
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
-
const handleSubmit = async values => {
|
|
140
|
+
const handleSubmit = async (values) => {
|
|
141
141
|
setIsSubmiting(true);
|
|
142
142
|
|
|
143
143
|
lockApp();
|
|
@@ -196,7 +196,7 @@ export const ProvidersPage = () => {
|
|
|
196
196
|
</Tr>
|
|
197
197
|
</Thead>
|
|
198
198
|
<Tbody>
|
|
199
|
-
{providers.map(provider => (
|
|
199
|
+
{providers.map((provider) => (
|
|
200
200
|
<Tr
|
|
201
201
|
key={provider.name}
|
|
202
202
|
{...onRowClick({
|
|
@@ -10,7 +10,7 @@ const initialState = {
|
|
|
10
10
|
|
|
11
11
|
const reducer = (state, action) =>
|
|
12
12
|
// eslint-disable-next-line consistent-return
|
|
13
|
-
produce(state, draftState => {
|
|
13
|
+
produce(state, (draftState) => {
|
|
14
14
|
switch (action.type) {
|
|
15
15
|
case 'GET_DATA': {
|
|
16
16
|
draftState.isLoading = true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestURL, axiosInstance } from '../../../utils';
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line import/prefer-default-export
|
|
4
|
-
export const fetchData = async toggleNotification => {
|
|
4
|
+
export const fetchData = async (toggleNotification) => {
|
|
5
5
|
try {
|
|
6
6
|
const { data } = await axiosInstance.get(getRequestURL('providers'));
|
|
7
7
|
|
|
@@ -16,6 +16,6 @@ export const fetchData = async toggleNotification => {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const putProvider = body => {
|
|
19
|
+
export const putProvider = (body) => {
|
|
20
20
|
return axiosInstance.put(getRequestURL('providers'), body);
|
|
21
21
|
};
|
|
@@ -36,7 +36,7 @@ const EditPage = () => {
|
|
|
36
36
|
const { trackUsage } = useTracking();
|
|
37
37
|
const permissionsRef = useRef();
|
|
38
38
|
|
|
39
|
-
const handleCreateRoleSubmit = async data => {
|
|
39
|
+
const handleCreateRoleSubmit = async (data) => {
|
|
40
40
|
// Set loading state
|
|
41
41
|
lockApp();
|
|
42
42
|
setIsSubmitting(true);
|
|
@@ -40,7 +40,7 @@ const EditPage = () => {
|
|
|
40
40
|
const { role, onSubmitSucceeded, isLoading: isLoadingRole } = useFetchRole(id);
|
|
41
41
|
const permissionsRef = useRef();
|
|
42
42
|
|
|
43
|
-
const handleEditRoleSubmit = async data => {
|
|
43
|
+
const handleEditRoleSubmit = async (data) => {
|
|
44
44
|
// Set loading state
|
|
45
45
|
lockApp();
|
|
46
46
|
setIsSubmitting(true);
|
|
@@ -17,20 +17,21 @@ const TableBody = ({ sortedRoles, canDelete, permissions, setRoleToDelete, onDel
|
|
|
17
17
|
const { push } = useHistory();
|
|
18
18
|
const [showConfirmDelete, setShowConfirmDelete] = onDelete;
|
|
19
19
|
|
|
20
|
-
const checkCanDeleteRole = role =>
|
|
20
|
+
const checkCanDeleteRole = (role) =>
|
|
21
|
+
canDelete && !['public', 'authenticated'].includes(role.type);
|
|
21
22
|
|
|
22
|
-
const handleClickDelete = id => {
|
|
23
|
+
const handleClickDelete = (id) => {
|
|
23
24
|
setRoleToDelete(id);
|
|
24
25
|
setShowConfirmDelete(!showConfirmDelete);
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
const handleClickEdit = id => {
|
|
28
|
+
const handleClickEdit = (id) => {
|
|
28
29
|
push(`/settings/${pluginId}/roles/${id}`);
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
33
|
<Tbody>
|
|
33
|
-
{sortedRoles?.map(role => (
|
|
34
|
+
{sortedRoles?.map((role) => (
|
|
34
35
|
<Tr key={role.name} {...onRowClick({ fn: () => handleClickEdit(role.id) })}>
|
|
35
36
|
<Td width="20%">
|
|
36
37
|
<Typography>{role.name}</Typography>
|
|
@@ -97,8 +97,8 @@ const RoleListPage = () => {
|
|
|
97
97
|
defaultMessage: 'Roles',
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
const deleteMutation = useMutation(id => deleteData(id, toggleNotification), {
|
|
101
|
-
|
|
100
|
+
const deleteMutation = useMutation((id) => deleteData(id, toggleNotification), {
|
|
101
|
+
async onSuccess() {
|
|
102
102
|
await queryClient.invalidateQueries('get-roles');
|
|
103
103
|
},
|
|
104
104
|
});
|
|
@@ -131,7 +131,7 @@ const RoleListPage = () => {
|
|
|
131
131
|
})}
|
|
132
132
|
primaryAction={
|
|
133
133
|
<CheckPermissions permissions={permissions.createRole}>
|
|
134
|
-
<Button onClick={handleNewRoleClick} startIcon={<Plus />} size="
|
|
134
|
+
<Button onClick={handleNewRoleClick} startIcon={<Plus />} size="S">
|
|
135
135
|
{formatMessage({
|
|
136
136
|
id: getTrad('List.button.roles'),
|
|
137
137
|
defaultMessage: 'Add new role',
|
|
@@ -6,7 +6,7 @@ const instance = axios.create({
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
instance.interceptors.request.use(
|
|
9
|
-
async config => {
|
|
9
|
+
async (config) => {
|
|
10
10
|
config.headers = {
|
|
11
11
|
Authorization: `Bearer ${auth.getToken()}`,
|
|
12
12
|
Accept: 'application/json',
|
|
@@ -15,14 +15,14 @@ instance.interceptors.request.use(
|
|
|
15
15
|
|
|
16
16
|
return config;
|
|
17
17
|
},
|
|
18
|
-
error => {
|
|
18
|
+
(error) => {
|
|
19
19
|
Promise.reject(error);
|
|
20
20
|
}
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
instance.interceptors.response.use(
|
|
24
|
-
response => response,
|
|
25
|
-
error => {
|
|
24
|
+
(response) => response,
|
|
25
|
+
(error) => {
|
|
26
26
|
// whatever you want to do with the error
|
|
27
27
|
if (error.response?.status === 401) {
|
|
28
28
|
auth.clearAppStorage();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isEmpty } from 'lodash';
|
|
2
2
|
|
|
3
|
-
const cleanPermissions = permissions =>
|
|
3
|
+
const cleanPermissions = (permissions) =>
|
|
4
4
|
Object.keys(permissions).reduce((acc, current) => {
|
|
5
5
|
const currentPermission = permissions[current].controllers;
|
|
6
6
|
const cleanedControllers = Object.keys(currentPermission).reduce((acc2, curr) => {
|
|
@@ -44,7 +44,7 @@ paths:
|
|
|
44
44
|
password:
|
|
45
45
|
type: string
|
|
46
46
|
example:
|
|
47
|
-
|
|
47
|
+
identifier: foobar
|
|
48
48
|
password: Test1234
|
|
49
49
|
required: true
|
|
50
50
|
responses:
|
|
@@ -102,6 +102,13 @@ paths:
|
|
|
102
102
|
tags:
|
|
103
103
|
- Users-Permissions - Auth
|
|
104
104
|
summary: Default Callback from provider auth
|
|
105
|
+
parameters:
|
|
106
|
+
- name: provider
|
|
107
|
+
in: path
|
|
108
|
+
required: true
|
|
109
|
+
description: Provider name
|
|
110
|
+
schema:
|
|
111
|
+
type: string
|
|
105
112
|
responses:
|
|
106
113
|
200:
|
|
107
114
|
description: Returns a jwt token and user info
|
|
@@ -196,15 +203,16 @@ paths:
|
|
|
196
203
|
application/json:
|
|
197
204
|
schema:
|
|
198
205
|
type: object
|
|
206
|
+
required:
|
|
207
|
+
- password
|
|
208
|
+
- currentPassword
|
|
209
|
+
- passwordConfirmation
|
|
199
210
|
properties:
|
|
200
211
|
password:
|
|
201
|
-
required: true
|
|
202
212
|
type: string
|
|
203
213
|
currentPassword:
|
|
204
|
-
required: true
|
|
205
214
|
type: string
|
|
206
215
|
passwordConfirmation:
|
|
207
|
-
required: true
|
|
208
216
|
type: string
|
|
209
217
|
responses:
|
|
210
218
|
200:
|
|
@@ -219,7 +227,6 @@ paths:
|
|
|
219
227
|
application/json:
|
|
220
228
|
schema:
|
|
221
229
|
$ref: '#/components/schemas/Error'
|
|
222
|
-
|
|
223
230
|
/auth/email-confirmation:
|
|
224
231
|
get:
|
|
225
232
|
tags:
|
|
@@ -228,7 +235,8 @@ paths:
|
|
|
228
235
|
parameters:
|
|
229
236
|
- in: query
|
|
230
237
|
name: confirmation
|
|
231
|
-
|
|
238
|
+
schema:
|
|
239
|
+
type: string
|
|
232
240
|
description: confirmation token received by email
|
|
233
241
|
responses:
|
|
234
242
|
301:
|
|
@@ -319,7 +327,6 @@ paths:
|
|
|
319
327
|
application/json:
|
|
320
328
|
schema:
|
|
321
329
|
$ref: '#/components/schemas/Error'
|
|
322
|
-
|
|
323
330
|
/users-permissions/roles:
|
|
324
331
|
get:
|
|
325
332
|
tags:
|
|
@@ -364,7 +371,7 @@ paths:
|
|
|
364
371
|
- Users-Permissions - Users & Roles
|
|
365
372
|
summary: Create a role
|
|
366
373
|
requestBody:
|
|
367
|
-
$ref: '#/components/
|
|
374
|
+
$ref: '#/components/requestBodies/Users-Permissions-RoleRequest'
|
|
368
375
|
responses:
|
|
369
376
|
200:
|
|
370
377
|
description: Returns ok if the role was create
|
|
@@ -391,10 +398,13 @@ paths:
|
|
|
391
398
|
parameters:
|
|
392
399
|
- in: path
|
|
393
400
|
name: id
|
|
394
|
-
|
|
401
|
+
required: true
|
|
402
|
+
schema:
|
|
403
|
+
type: string
|
|
395
404
|
description: role Id
|
|
396
405
|
responses:
|
|
397
406
|
200:
|
|
407
|
+
description: Returns the role
|
|
398
408
|
content:
|
|
399
409
|
application/json:
|
|
400
410
|
schema:
|
|
@@ -431,10 +441,12 @@ paths:
|
|
|
431
441
|
parameters:
|
|
432
442
|
- in: path
|
|
433
443
|
name: role
|
|
434
|
-
|
|
444
|
+
required: true
|
|
445
|
+
schema:
|
|
446
|
+
type: string
|
|
435
447
|
description: role Id
|
|
436
448
|
requestBody:
|
|
437
|
-
$ref: '#/components/
|
|
449
|
+
$ref: '#/components/requestBodies/Users-Permissions-RoleRequest'
|
|
438
450
|
responses:
|
|
439
451
|
200:
|
|
440
452
|
description: Returns ok if the role was udpated
|
|
@@ -460,7 +472,9 @@ paths:
|
|
|
460
472
|
parameters:
|
|
461
473
|
- in: path
|
|
462
474
|
name: role
|
|
463
|
-
|
|
475
|
+
required: true
|
|
476
|
+
schema:
|
|
477
|
+
type: string
|
|
464
478
|
description: role Id
|
|
465
479
|
responses:
|
|
466
480
|
200:
|
|
@@ -487,7 +501,7 @@ paths:
|
|
|
487
501
|
summary: Get list of users
|
|
488
502
|
responses:
|
|
489
503
|
200:
|
|
490
|
-
|
|
504
|
+
description: Returns an array of users
|
|
491
505
|
content:
|
|
492
506
|
application/json:
|
|
493
507
|
schema:
|
|
@@ -520,17 +534,17 @@ paths:
|
|
|
520
534
|
application/json:
|
|
521
535
|
schema:
|
|
522
536
|
type: object
|
|
537
|
+
required:
|
|
538
|
+
- username
|
|
539
|
+
- email
|
|
540
|
+
- password
|
|
523
541
|
properties:
|
|
524
542
|
email:
|
|
525
543
|
type: string
|
|
526
|
-
required: true
|
|
527
544
|
username:
|
|
528
545
|
type: string
|
|
529
|
-
required: true
|
|
530
546
|
password:
|
|
531
547
|
type: string
|
|
532
|
-
required: true
|
|
533
|
-
|
|
534
548
|
example:
|
|
535
549
|
username: foo
|
|
536
550
|
email: foo@strapi.io
|
|
@@ -569,7 +583,6 @@ paths:
|
|
|
569
583
|
application/json:
|
|
570
584
|
schema:
|
|
571
585
|
$ref: '#/components/schemas/Error'
|
|
572
|
-
|
|
573
586
|
/users/{id}:
|
|
574
587
|
get:
|
|
575
588
|
tags:
|
|
@@ -578,10 +591,13 @@ paths:
|
|
|
578
591
|
parameters:
|
|
579
592
|
- in: path
|
|
580
593
|
name: id
|
|
581
|
-
|
|
594
|
+
required: true
|
|
595
|
+
schema:
|
|
596
|
+
type: string
|
|
582
597
|
description: user Id
|
|
583
598
|
responses:
|
|
584
599
|
200:
|
|
600
|
+
description: Returns a user
|
|
585
601
|
content:
|
|
586
602
|
application/json:
|
|
587
603
|
schema:
|
|
@@ -601,7 +617,6 @@ paths:
|
|
|
601
617
|
application/json:
|
|
602
618
|
schema:
|
|
603
619
|
$ref: '#/components/schemas/Error'
|
|
604
|
-
|
|
605
620
|
put:
|
|
606
621
|
tags:
|
|
607
622
|
- Users-Permissions - Users & Roles
|
|
@@ -609,7 +624,9 @@ paths:
|
|
|
609
624
|
parameters:
|
|
610
625
|
- in: path
|
|
611
626
|
name: id
|
|
612
|
-
|
|
627
|
+
required: true
|
|
628
|
+
schema:
|
|
629
|
+
type: string
|
|
613
630
|
description: user Id
|
|
614
631
|
requestBody:
|
|
615
632
|
required: true
|
|
@@ -617,17 +634,17 @@ paths:
|
|
|
617
634
|
application/json:
|
|
618
635
|
schema:
|
|
619
636
|
type: object
|
|
637
|
+
required:
|
|
638
|
+
- username
|
|
639
|
+
- email
|
|
640
|
+
- password
|
|
620
641
|
properties:
|
|
621
642
|
email:
|
|
622
643
|
type: string
|
|
623
|
-
required: true
|
|
624
644
|
username:
|
|
625
645
|
type: string
|
|
626
|
-
required: true
|
|
627
646
|
password:
|
|
628
647
|
type: string
|
|
629
|
-
required: true
|
|
630
|
-
|
|
631
648
|
example:
|
|
632
649
|
username: foo
|
|
633
650
|
email: foo@strapi.io
|
|
@@ -666,13 +683,19 @@ paths:
|
|
|
666
683
|
application/json:
|
|
667
684
|
schema:
|
|
668
685
|
$ref: '#/components/schemas/Error'
|
|
669
|
-
|
|
670
686
|
delete:
|
|
671
687
|
tags:
|
|
672
688
|
- Users-Permissions - Users & Roles
|
|
673
689
|
summary: Delete a user
|
|
690
|
+
parameters:
|
|
691
|
+
- in: path
|
|
692
|
+
name: id
|
|
693
|
+
required: true
|
|
694
|
+
schema:
|
|
695
|
+
type: string
|
|
696
|
+
description: user Id
|
|
674
697
|
responses:
|
|
675
|
-
200:
|
|
698
|
+
"200":
|
|
676
699
|
description: Returns deleted user info
|
|
677
700
|
content:
|
|
678
701
|
application/json:
|
|
@@ -817,6 +840,10 @@ components:
|
|
|
817
840
|
policy:
|
|
818
841
|
type: string
|
|
819
842
|
|
|
843
|
+
parameters:
|
|
844
|
+
responses:
|
|
845
|
+
examples:
|
|
846
|
+
requestBodies:
|
|
820
847
|
Users-Permissions-RoleRequest:
|
|
821
848
|
required: true
|
|
822
849
|
content:
|
|
@@ -842,7 +869,3 @@ components:
|
|
|
842
869
|
find:
|
|
843
870
|
enabled: true
|
|
844
871
|
|
|
845
|
-
parameters:
|
|
846
|
-
responses:
|
|
847
|
-
examples:
|
|
848
|
-
requestBodies:
|
package/jest.config.front.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-users-permissions",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.7",
|
|
4
4
|
"description": "Protect your API with a full-authentication process based on JWT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,26 +27,31 @@
|
|
|
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.3.
|
|
31
|
-
"@strapi/utils": "4.3.
|
|
30
|
+
"@strapi/helper-plugin": "4.3.7",
|
|
31
|
+
"@strapi/utils": "4.3.7",
|
|
32
32
|
"bcryptjs": "2.4.3",
|
|
33
33
|
"grant-koa": "5.4.8",
|
|
34
34
|
"jsonwebtoken": "^8.1.0",
|
|
35
|
+
"koa": "^2.13.4",
|
|
35
36
|
"koa2-ratelimit": "^1.1.1",
|
|
36
37
|
"lodash": "4.17.21",
|
|
37
38
|
"purest": "4.0.2",
|
|
38
39
|
"react": "^17.0.2",
|
|
39
40
|
"react-dom": "^17.0.2",
|
|
40
|
-
"react-intl": "5.
|
|
41
|
+
"react-intl": "5.25.1",
|
|
41
42
|
"react-redux": "7.2.8",
|
|
42
43
|
"react-router": "^5.2.0",
|
|
43
44
|
"react-router-dom": "5.2.0",
|
|
44
|
-
"redux-saga": "^0.16.0",
|
|
45
45
|
"request": "^2.83.0",
|
|
46
46
|
"url-join": "4.0.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"
|
|
49
|
+
"@testing-library/dom": "8.17.1",
|
|
50
|
+
"@testing-library/react": "12.1.4",
|
|
51
|
+
"@testing-library/react-hooks": "8.0.1",
|
|
52
|
+
"@testing-library/user-event": "14.4.2",
|
|
53
|
+
"msw": "0.42.3",
|
|
54
|
+
"react-test-renderer": "^17.0.2"
|
|
50
55
|
},
|
|
51
56
|
"engines": {
|
|
52
57
|
"node": ">=14.19.1 <=16.x.x",
|
|
@@ -59,5 +64,5 @@
|
|
|
59
64
|
"required": true,
|
|
60
65
|
"kind": "plugin"
|
|
61
66
|
},
|
|
62
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "73f523b98322cea8992c72977b94a73a624d2e79"
|
|
63
68
|
}
|
|
@@ -15,42 +15,7 @@ const getGrantConfig = require('./grant-config');
|
|
|
15
15
|
|
|
16
16
|
const usersPermissionsActions = require('./users-permissions-actions');
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
const pluginStore = strapi.store({ type: 'plugin', name: 'users-permissions' });
|
|
20
|
-
|
|
21
|
-
await initGrant(pluginStore);
|
|
22
|
-
await initEmails(pluginStore);
|
|
23
|
-
await initAdvancedOptions(pluginStore);
|
|
24
|
-
|
|
25
|
-
await strapi.admin.services.permission.actionProvider.registerMany(
|
|
26
|
-
usersPermissionsActions.actions
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
await getService('users-permissions').initialize();
|
|
30
|
-
|
|
31
|
-
if (!strapi.config.get('plugin.users-permissions.jwtSecret')) {
|
|
32
|
-
if (process.env.NODE_ENV !== 'development') {
|
|
33
|
-
throw new Error(
|
|
34
|
-
`Missing jwtSecret. Please, set configuration variable "jwtSecret" for the users-permissions plugin in config/plugins.js (ex: you can generate one using Node with \`crypto.randomBytes(16).toString('base64')\`).
|
|
35
|
-
For security reasons, prefer storing the secret in an environment variable and read it in config/plugins.js. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables.`
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const jwtSecret = crypto.randomBytes(16).toString('base64');
|
|
40
|
-
|
|
41
|
-
strapi.config.set('plugin.users-permissions.jwtSecret', jwtSecret);
|
|
42
|
-
|
|
43
|
-
if (!process.env.JWT_SECRET) {
|
|
44
|
-
const envPath = process.env.ENV_PATH || '.env';
|
|
45
|
-
strapi.fs.appendFile(envPath, `JWT_SECRET=${jwtSecret}\n`);
|
|
46
|
-
strapi.log.info(
|
|
47
|
-
`The Users & Permissions plugin automatically generated a jwt secret and stored it in ${envPath} under the name JWT_SECRET.`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const initGrant = async pluginStore => {
|
|
18
|
+
const initGrant = async (pluginStore) => {
|
|
54
19
|
const apiPrefix = strapi.config.get('api.rest.prefix');
|
|
55
20
|
const baseURL = urljoin(strapi.config.server.url, apiPrefix, 'auth');
|
|
56
21
|
|
|
@@ -62,7 +27,7 @@ const initGrant = async pluginStore => {
|
|
|
62
27
|
// or we have added/deleted provider here.
|
|
63
28
|
if (!prevGrantConfig || !_.isEqual(_.keys(prevGrantConfig), _.keys(grantConfig))) {
|
|
64
29
|
// merge with the previous provider config.
|
|
65
|
-
_.keys(grantConfig).forEach(key => {
|
|
30
|
+
_.keys(grantConfig).forEach((key) => {
|
|
66
31
|
if (key in prevGrantConfig) {
|
|
67
32
|
grantConfig[key] = _.merge(grantConfig[key], prevGrantConfig[key]);
|
|
68
33
|
}
|
|
@@ -71,7 +36,7 @@ const initGrant = async pluginStore => {
|
|
|
71
36
|
}
|
|
72
37
|
};
|
|
73
38
|
|
|
74
|
-
const initEmails = async pluginStore => {
|
|
39
|
+
const initEmails = async (pluginStore) => {
|
|
75
40
|
if (!(await pluginStore.get({ key: 'email' }))) {
|
|
76
41
|
const value = {
|
|
77
42
|
reset_password: {
|
|
@@ -117,7 +82,7 @@ const initEmails = async pluginStore => {
|
|
|
117
82
|
}
|
|
118
83
|
};
|
|
119
84
|
|
|
120
|
-
const initAdvancedOptions = async pluginStore => {
|
|
85
|
+
const initAdvancedOptions = async (pluginStore) => {
|
|
121
86
|
if (!(await pluginStore.get({ key: 'advanced' }))) {
|
|
122
87
|
const value = {
|
|
123
88
|
unique_email: true,
|
|
@@ -131,3 +96,38 @@ const initAdvancedOptions = async pluginStore => {
|
|
|
131
96
|
await pluginStore.set({ key: 'advanced', value });
|
|
132
97
|
}
|
|
133
98
|
};
|
|
99
|
+
|
|
100
|
+
module.exports = async ({ strapi }) => {
|
|
101
|
+
const pluginStore = strapi.store({ type: 'plugin', name: 'users-permissions' });
|
|
102
|
+
|
|
103
|
+
await initGrant(pluginStore);
|
|
104
|
+
await initEmails(pluginStore);
|
|
105
|
+
await initAdvancedOptions(pluginStore);
|
|
106
|
+
|
|
107
|
+
await strapi.admin.services.permission.actionProvider.registerMany(
|
|
108
|
+
usersPermissionsActions.actions
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
await getService('users-permissions').initialize();
|
|
112
|
+
|
|
113
|
+
if (!strapi.config.get('plugin.users-permissions.jwtSecret')) {
|
|
114
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`Missing jwtSecret. Please, set configuration variable "jwtSecret" for the users-permissions plugin in config/plugins.js (ex: you can generate one using Node with \`crypto.randomBytes(16).toString('base64')\`).
|
|
117
|
+
For security reasons, prefer storing the secret in an environment variable and read it in config/plugins.js. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables.`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const jwtSecret = crypto.randomBytes(16).toString('base64');
|
|
122
|
+
|
|
123
|
+
strapi.config.set('plugin.users-permissions.jwtSecret', jwtSecret);
|
|
124
|
+
|
|
125
|
+
if (!process.env.JWT_SECRET) {
|
|
126
|
+
const envPath = process.env.ENV_PATH || '.env';
|
|
127
|
+
strapi.fs.appendFile(envPath, `JWT_SECRET=${jwtSecret}\n`);
|
|
128
|
+
strapi.log.info(
|
|
129
|
+
`The Users & Permissions plugin automatically generated a jwt secret and stored it in ${envPath} under the name JWT_SECRET.`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|