@azteam/express 1.2.262 → 1.2.264
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/package.json
CHANGED
|
@@ -33,9 +33,9 @@ export default function (cbLoginAPI) {
|
|
|
33
33
|
return next();
|
|
34
34
|
} catch (err) {
|
|
35
35
|
if (err.name === 'TokenExpiredError') {
|
|
36
|
-
|
|
36
|
+
throw new ErrorException(TOKEN_EXPIRED, err);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
throw new ErrorException(TOKEN_FAILED, err);
|
|
39
39
|
}
|
|
40
40
|
} else {
|
|
41
41
|
const data = await cbLoginAPI(token);
|
|
@@ -72,7 +72,7 @@ export default function (options = {}) {
|
|
|
72
72
|
if (!options.searchFields.includes(key)) {
|
|
73
73
|
delete req.query[key];
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
// throw new ErrorException(INVALID, `Not exists search ${key}`);
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
|
|
@@ -92,10 +92,11 @@ export default function (options = {}) {
|
|
|
92
92
|
|
|
93
93
|
if (req.query.autocomplete) {
|
|
94
94
|
if (!options.autocompleteField) {
|
|
95
|
-
|
|
95
|
+
throw new ErrorException(INVALID, 'Not exists autocomplete field');
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
req.query = {
|
|
99
|
+
...req.query,
|
|
99
100
|
[options.autocompleteField]: {
|
|
100
101
|
$regex: req.query.autocomplete,
|
|
101
102
|
$options: 'i',
|
|
@@ -3,14 +3,14 @@ import {ErrorException, PERMISSION, UNAUTHORIZED} from '@azteam/error';
|
|
|
3
3
|
export default function (roles = null, minLevel = 1) {
|
|
4
4
|
return async function (req, res, next) {
|
|
5
5
|
if (!req.user) {
|
|
6
|
-
|
|
6
|
+
throw new ErrorException(UNAUTHORIZED);
|
|
7
7
|
}
|
|
8
8
|
if (req.user.level < minLevel) {
|
|
9
|
-
|
|
9
|
+
throw new ErrorException(PERMISSION);
|
|
10
10
|
}
|
|
11
11
|
if (!roles || req.user.level === 100 || req.user.roles.some((r) => roles.includes(r))) {
|
|
12
12
|
return next();
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
throw new ErrorException(PERMISSION);
|
|
15
15
|
};
|
|
16
16
|
}
|