@nest-omni/core 1.0.34 → 1.0.38

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.
@@ -8,12 +8,12 @@ exports.User = (0, common_1.createParamDecorator)((data, ctx) => {
8
8
  });
9
9
  function getUserData(req, data) {
10
10
  const headers = req.headers;
11
- if (lodash.isEmpty(headers['x-userid']) ||
11
+ if (lodash.isEmpty(headers['x-user-id']) ||
12
12
  lodash.isEmpty(headers['x-username'])) {
13
13
  return null;
14
14
  }
15
15
  const user = {
16
- uid: headers['x-userid'],
16
+ uid: headers['x-user-id'],
17
17
  username: headers['x-username'],
18
18
  };
19
19
  return data ? user[data] : user;
@@ -13,7 +13,7 @@ function getOmniAuthData(request, key) {
13
13
  const headers = request.headers;
14
14
  let user;
15
15
  const configService = new config_1.ConfigService(request);
16
- if ((0, lodash_1.isEmpty)(headers['x-userid']) || (0, lodash_1.isEmpty)(headers['x-username'])) {
16
+ if ((0, lodash_1.isEmpty)(headers['x-user-id']) || (0, lodash_1.isEmpty)(headers['x-username'])) {
17
17
  if (process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'uat') {
18
18
  user = {
19
19
  uid: configService.get('MOCK_UID'),
@@ -24,13 +24,17 @@ function getOmniAuthData(request, key) {
24
24
  role: configService.get('MOCK_ROLE', ''),
25
25
  };
26
26
  }
27
+ else {
28
+ console.error('User information is not transparently transmitted through the gateway: ' +
29
+ headers);
30
+ }
27
31
  }
28
32
  else {
29
33
  user = {
30
- uid: headers['x-userid'] || '',
34
+ uid: headers['x-user-id'] || '',
31
35
  username: headers['x-username'] || '',
32
- appId: headers['x-appid'] || '',
33
- tenantId: headers['x-tenantid'] || '',
36
+ appId: headers['x-app-id'] || '',
37
+ tenantId: headers['x-tenant-id'] || '',
34
38
  admin: headers['x-admin'] === '1',
35
39
  role: headers['x-role'] || '',
36
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-omni/core",
3
- "version": "1.0.34",
3
+ "version": "1.0.38",
4
4
  "description": "framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ContextProvider = void 0;
4
4
  const nestjs_cls_1 = require("nestjs-cls");
5
+ const common_1 = require("@nestjs/common");
5
6
  class ContextProvider {
6
7
  static get(key) {
7
8
  const store = nestjs_cls_1.ClsServiceManager.getClsService();
@@ -54,7 +55,7 @@ class ContextProvider {
54
55
  static getAuthUser() {
55
56
  const auth = ContextProvider.get(ContextProvider.authUserKey);
56
57
  if (!auth) {
57
- throw new Error('User information not found.');
58
+ throw new common_1.BadGatewayException('User information not found.');
58
59
  }
59
60
  return auth;
60
61
  }