@azteam/express 1.2.259 → 1.2.261
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,16 +33,16 @@ export default function (cbLoginAPI) {
|
|
|
33
33
|
return next();
|
|
34
34
|
} catch (err) {
|
|
35
35
|
if (err.name === 'TokenExpiredError') {
|
|
36
|
-
|
|
36
|
+
return next(new ErrorException(TOKEN_EXPIRED, err));
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
return next(new ErrorException(TOKEN_FAILED, err));
|
|
39
39
|
}
|
|
40
40
|
} else {
|
|
41
41
|
const data = await cbLoginAPI(token);
|
|
42
42
|
if (data) {
|
|
43
43
|
req.user = data;
|
|
44
44
|
} else {
|
|
45
|
-
|
|
45
|
+
return next(ErrorException(TOKEN_FAILED));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
+
import {ErrorException, INVALID} from '@azteam/error';
|
|
2
3
|
|
|
3
4
|
function omitData(data) {
|
|
4
5
|
Object.keys(data).map(function (key) {
|
|
@@ -70,6 +71,8 @@ export default function (options = {}) {
|
|
|
70
71
|
|
|
71
72
|
if (!options.searchFields.includes(key)) {
|
|
72
73
|
delete req.query[key];
|
|
74
|
+
|
|
75
|
+
return next(new ErrorException(INVALID, `Not exists search ${key}`));
|
|
73
76
|
}
|
|
74
77
|
});
|
|
75
78
|
|
|
@@ -87,6 +90,19 @@ export default function (options = {}) {
|
|
|
87
90
|
};
|
|
88
91
|
}
|
|
89
92
|
|
|
93
|
+
if (req.query.autocomplete) {
|
|
94
|
+
if (!options.autocompleteField) {
|
|
95
|
+
return next(new ErrorException(INVALID, 'Not exists autocomplete field'));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
req.query = {
|
|
99
|
+
[options.autocompleteField]: {
|
|
100
|
+
$regex: `/${req.query.autocomplete}/`,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
delete req.query.autocomplete;
|
|
104
|
+
}
|
|
105
|
+
|
|
90
106
|
return next();
|
|
91
107
|
};
|
|
92
108
|
}
|