exodus-framework 2.0.61 → 2.0.63
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.
@@ -3,6 +3,7 @@ import HttpController from '../app/controller';
|
|
3
3
|
import { TAccountType } from '../contracts';
|
4
4
|
declare class AccessMiddleware extends HttpController {
|
5
5
|
accessLevel: (level: TAccountType[]) => RequestHandler;
|
6
|
+
getConnection: RequestHandler;
|
6
7
|
}
|
7
8
|
export default AccessMiddleware;
|
8
9
|
//# sourceMappingURL=access.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/middlewares/access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/middlewares/access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAK5C,cAAM,gBAAiB,SAAQ,cAAc;IAC3C,WAAW,UAAW,YAAY,EAAE,KAAG,cAAc,CAWnD;IAEF,aAAa,EAAE,cAAc,CAqB3B;CACH;AAED,eAAe,gBAAgB,CAAC"}
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.default = void 0;
|
7
7
|
var _controller = _interopRequireDefault(require("../app/controller"));
|
8
8
|
var _http = require("../contracts/http");
|
9
|
+
var _services = require("../services");
|
9
10
|
var _error = require("../services/error");
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
11
12
|
class AccessMiddleware extends _controller.default {
|
@@ -17,5 +18,21 @@ class AccessMiddleware extends _controller.default {
|
|
17
18
|
next();
|
18
19
|
};
|
19
20
|
};
|
21
|
+
getConnection = async (req, res, next) => {
|
22
|
+
const account = req.auth.account;
|
23
|
+
const envToken = req.header('X-Exodus-Environment-Token');
|
24
|
+
const connUuid = req.header('X-Exodus-Connection');
|
25
|
+
if (account && account.type != 'ADMINISTRATOR') {
|
26
|
+
if (!envToken || !connUuid) {
|
27
|
+
throw new _error.ApplicationHttpException('Informações do ambiente incompletas', _http.EHttpResponseCode.incompleteRequest);
|
28
|
+
}
|
29
|
+
const connection = await _services.SequelizeService.singleton().getDB(connUuid, envToken);
|
30
|
+
if (!connection) {
|
31
|
+
throw new _error.ApplicationHttpException('Não foi possível obter a conexão deste ambiente');
|
32
|
+
}
|
33
|
+
req.auth.connection = connection;
|
34
|
+
}
|
35
|
+
next();
|
36
|
+
};
|
20
37
|
}
|
21
38
|
var _default = exports.default = AccessMiddleware;
|