@riocrypto/common 1.0.389 → 1.0.391
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.
|
@@ -23,6 +23,7 @@ const kyc_status_1 = require("../types/kyc-status");
|
|
|
23
23
|
const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
24
|
var _a, _b;
|
|
25
25
|
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth)) {
|
|
26
|
+
console.log("got auth");
|
|
26
27
|
if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.jwt) {
|
|
27
28
|
try {
|
|
28
29
|
const payload = jsonwebtoken_1.default.verify(req.cookies.jwt, process.env.JWT_KEY);
|
|
@@ -33,6 +34,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
33
34
|
}
|
|
34
35
|
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Admin)) {
|
|
35
36
|
if ((_b = req.cookies) === null || _b === void 0 ? void 0 : _b.adminJwt) {
|
|
37
|
+
console.log("got admin");
|
|
36
38
|
try {
|
|
37
39
|
const payload = jsonwebtoken_1.default.verify(req.cookies.adminJwt, process.env.JWT_KEY_ADMIN);
|
|
38
40
|
req.currentAdminAuth = payload;
|
|
@@ -99,10 +101,15 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
99
101
|
}
|
|
100
102
|
const user = individualUser || businessUser;
|
|
101
103
|
if (user) {
|
|
104
|
+
console.log("got user");
|
|
102
105
|
req.user = user;
|
|
103
106
|
}
|
|
104
107
|
}
|
|
108
|
+
console.log("currentAdminAuth", req.currentAdminAuth);
|
|
109
|
+
console.log("currentAuth", req.currentAuth);
|
|
110
|
+
console.log("user", req.user);
|
|
105
111
|
if (!req.currentAdminAuth && !req.currentAuth && !req.user) {
|
|
112
|
+
console.log("throwing error");
|
|
106
113
|
throw new not_authorized_error_1.NotAuthorizedError();
|
|
107
114
|
}
|
|
108
115
|
next();
|