@strapi/plugin-users-permissions 4.10.0-beta.1 → 4.10.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.
- package/admin/src/hooks/useForm/index.js +4 -7
- package/admin/src/hooks/useRolesList/index.js +18 -19
- package/documentation/content-api.yaml +22 -14
- package/package.json +4 -4
- package/server/controllers/auth.js +6 -0
- package/server/register.js +7 -1
- package/server/services/providers-registry.js +1 -1
- package/server/strategies/users-permissions.js +8 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
|
2
|
-
import { useRBAC,
|
|
2
|
+
import { useRBAC, useFetchClient, useNotification } from '@strapi/helper-plugin';
|
|
3
3
|
import { getRequestURL } from '../../utils';
|
|
4
4
|
import reducer, { initialState } from './reducer';
|
|
5
5
|
|
|
@@ -9,8 +9,7 @@ const useUserForm = (endPoint, permissions) => {
|
|
|
9
9
|
const toggleNotification = useNotification();
|
|
10
10
|
const isMounted = useRef(true);
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const { signal } = abortController;
|
|
12
|
+
const { get } = useFetchClient();
|
|
14
13
|
|
|
15
14
|
useEffect(() => {
|
|
16
15
|
const getData = async () => {
|
|
@@ -19,7 +18,7 @@ const useUserForm = (endPoint, permissions) => {
|
|
|
19
18
|
type: 'GET_DATA',
|
|
20
19
|
});
|
|
21
20
|
|
|
22
|
-
const data = await
|
|
21
|
+
const { data } = await get(getRequestURL(endPoint));
|
|
23
22
|
|
|
24
23
|
dispatch({
|
|
25
24
|
type: 'GET_DATA_SUCCEEDED',
|
|
@@ -45,11 +44,9 @@ const useUserForm = (endPoint, permissions) => {
|
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
return () => {
|
|
48
|
-
abortController.abort();
|
|
49
47
|
isMounted.current = false;
|
|
50
48
|
};
|
|
51
|
-
|
|
52
|
-
}, [isLoadingForPermissions, endPoint]);
|
|
49
|
+
}, [isLoadingForPermissions, endPoint, get, toggleNotification]);
|
|
53
50
|
|
|
54
51
|
const dispatchSubmitSucceeded = useCallback((data) => {
|
|
55
52
|
dispatch({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEffect, useReducer, useRef } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
|
2
|
+
import { useFetchClient, useNotification } from '@strapi/helper-plugin';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
4
|
import init from './init';
|
|
5
5
|
import pluginId from '../../pluginId';
|
|
@@ -12,28 +12,17 @@ const useRolesList = (shouldFetchData = true) => {
|
|
|
12
12
|
const toggleNotification = useNotification();
|
|
13
13
|
|
|
14
14
|
const isMounted = useRef(true);
|
|
15
|
-
const
|
|
16
|
-
const { signal } = abortController;
|
|
15
|
+
const fetchClient = useFetchClient();
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
if (shouldFetchData) {
|
|
20
|
-
fetchRolesList();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return () => {
|
|
24
|
-
abortController.abort();
|
|
25
|
-
isMounted.current = false;
|
|
26
|
-
};
|
|
27
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
-
}, [shouldFetchData]);
|
|
29
|
-
|
|
30
|
-
const fetchRolesList = async () => {
|
|
17
|
+
const fetchRolesList = useCallback(async () => {
|
|
31
18
|
try {
|
|
32
19
|
dispatch({
|
|
33
20
|
type: 'GET_DATA',
|
|
34
21
|
});
|
|
35
22
|
|
|
36
|
-
const {
|
|
23
|
+
const {
|
|
24
|
+
data: { roles },
|
|
25
|
+
} = await fetchClient.get(`/${pluginId}/roles`);
|
|
37
26
|
|
|
38
27
|
dispatch({
|
|
39
28
|
type: 'GET_DATA_SUCCEEDED',
|
|
@@ -55,7 +44,17 @@ const useRolesList = (shouldFetchData = true) => {
|
|
|
55
44
|
}
|
|
56
45
|
}
|
|
57
46
|
}
|
|
58
|
-
};
|
|
47
|
+
}, [fetchClient, toggleNotification]);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (shouldFetchData) {
|
|
51
|
+
fetchRolesList();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return () => {
|
|
55
|
+
isMounted.current = false;
|
|
56
|
+
};
|
|
57
|
+
}, [shouldFetchData, fetchRolesList]);
|
|
59
58
|
|
|
60
59
|
return { roles, isLoading, getData: fetchRolesList };
|
|
61
60
|
};
|
|
@@ -12,8 +12,16 @@ tags:
|
|
|
12
12
|
url: 'https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html'
|
|
13
13
|
|
|
14
14
|
paths:
|
|
15
|
-
|
|
15
|
+
/connect/{provider}:
|
|
16
16
|
get:
|
|
17
|
+
parameters:
|
|
18
|
+
- name: provider
|
|
19
|
+
in: path
|
|
20
|
+
required: true
|
|
21
|
+
description: Provider name
|
|
22
|
+
schema:
|
|
23
|
+
type: string
|
|
24
|
+
pattern: '.*'
|
|
17
25
|
tags:
|
|
18
26
|
- Users-Permissions - Auth
|
|
19
27
|
summary: Login with a provider
|
|
@@ -148,7 +156,7 @@ paths:
|
|
|
148
156
|
type: object
|
|
149
157
|
properties:
|
|
150
158
|
ok:
|
|
151
|
-
type:
|
|
159
|
+
type: string
|
|
152
160
|
enum: [true]
|
|
153
161
|
default:
|
|
154
162
|
description: Error
|
|
@@ -273,7 +281,7 @@ paths:
|
|
|
273
281
|
email:
|
|
274
282
|
type: string
|
|
275
283
|
sent:
|
|
276
|
-
type:
|
|
284
|
+
type: string
|
|
277
285
|
enum: [true]
|
|
278
286
|
default:
|
|
279
287
|
description: Error
|
|
@@ -381,7 +389,7 @@ paths:
|
|
|
381
389
|
type: object
|
|
382
390
|
properties:
|
|
383
391
|
ok:
|
|
384
|
-
type:
|
|
392
|
+
type: string
|
|
385
393
|
enum: [true]
|
|
386
394
|
default:
|
|
387
395
|
description: Error
|
|
@@ -456,7 +464,7 @@ paths:
|
|
|
456
464
|
type: object
|
|
457
465
|
properties:
|
|
458
466
|
ok:
|
|
459
|
-
type:
|
|
467
|
+
type: string
|
|
460
468
|
enum: [true]
|
|
461
469
|
default:
|
|
462
470
|
description: Error
|
|
@@ -485,7 +493,7 @@ paths:
|
|
|
485
493
|
type: object
|
|
486
494
|
properties:
|
|
487
495
|
ok:
|
|
488
|
-
type:
|
|
496
|
+
type: string
|
|
489
497
|
enum: [true]
|
|
490
498
|
default:
|
|
491
499
|
description: Error
|
|
@@ -779,9 +787,11 @@ components:
|
|
|
779
787
|
type:
|
|
780
788
|
type: string
|
|
781
789
|
createdAt:
|
|
782
|
-
type:
|
|
790
|
+
type: string
|
|
791
|
+
format: date-time
|
|
783
792
|
updatedAt:
|
|
784
|
-
type:
|
|
793
|
+
type: string
|
|
794
|
+
format: date-time
|
|
785
795
|
|
|
786
796
|
Users-Permissions-User:
|
|
787
797
|
type: object
|
|
@@ -805,10 +815,12 @@ components:
|
|
|
805
815
|
type: boolean
|
|
806
816
|
example: false
|
|
807
817
|
createdAt:
|
|
808
|
-
type:
|
|
818
|
+
type: string
|
|
819
|
+
format: date-time
|
|
809
820
|
example: '2022-06-02T08:32:06.258Z'
|
|
810
821
|
updatedAt:
|
|
811
|
-
type:
|
|
822
|
+
type: string
|
|
823
|
+
format: date-time
|
|
812
824
|
example: '2022-06-02T08:32:06.267Z'
|
|
813
825
|
|
|
814
826
|
Users-Permissions-UserRegistration:
|
|
@@ -839,10 +851,6 @@ components:
|
|
|
839
851
|
type: boolean
|
|
840
852
|
policy:
|
|
841
853
|
type: string
|
|
842
|
-
|
|
843
|
-
parameters:
|
|
844
|
-
responses:
|
|
845
|
-
examples:
|
|
846
854
|
requestBodies:
|
|
847
855
|
Users-Permissions-RoleRequest:
|
|
848
856
|
required: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-users-permissions",
|
|
3
|
-
"version": "4.10.0
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "Protect your API with a full-authentication process based on JWT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@strapi/design-system": "1.6.6",
|
|
33
|
-
"@strapi/helper-plugin": "4.10.0
|
|
33
|
+
"@strapi/helper-plugin": "4.10.0",
|
|
34
34
|
"@strapi/icons": "1.6.6",
|
|
35
|
-
"@strapi/utils": "4.10.0
|
|
35
|
+
"@strapi/utils": "4.10.0",
|
|
36
36
|
"bcryptjs": "2.4.3",
|
|
37
37
|
"formik": "2.2.9",
|
|
38
38
|
"grant-koa": "5.4.8",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"required": true,
|
|
81
81
|
"kind": "plugin"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "9b5519778faaedfb837879f9c6f7e28fdfd6750d"
|
|
84
84
|
}
|
package/server/register.js
CHANGED
|
@@ -18,6 +18,12 @@ module.exports = ({ strapi }) => {
|
|
|
18
18
|
const specPath = path.join(__dirname, '../documentation/content-api.yaml');
|
|
19
19
|
const spec = fs.readFileSync(specPath, 'utf8');
|
|
20
20
|
|
|
21
|
-
strapi
|
|
21
|
+
strapi
|
|
22
|
+
.plugin('documentation')
|
|
23
|
+
.service('override')
|
|
24
|
+
.registerOverride(spec, {
|
|
25
|
+
pluginOrigin: 'users-permissions',
|
|
26
|
+
excludeFromGeneration: ['users-permissions'],
|
|
27
|
+
});
|
|
22
28
|
}
|
|
23
29
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { castArray, map, every, pipe } = require('lodash/fp');
|
|
3
|
+
const { castArray, map, every, pipe, isEmpty } = require('lodash/fp');
|
|
4
4
|
const { ForbiddenError, UnauthorizedError } = require('@strapi/utils').errors;
|
|
5
5
|
|
|
6
6
|
const { getService } = require('../utils');
|
|
@@ -80,6 +80,13 @@ const authenticate = async (ctx) => {
|
|
|
80
80
|
const verify = async (auth, config) => {
|
|
81
81
|
const { credentials: user, ability } = auth;
|
|
82
82
|
|
|
83
|
+
strapi.telemetry.send('didReceiveAPIRequest', {
|
|
84
|
+
eventProperties: {
|
|
85
|
+
authenticationMethod: auth?.strategy?.name,
|
|
86
|
+
isAuthenticated: !isEmpty(user),
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
83
90
|
if (!config.scope) {
|
|
84
91
|
if (!user) {
|
|
85
92
|
// A non authenticated user cannot access routes that do not have a scope
|