@riocrypto/common 1.0.394 → 1.0.396
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,7 +23,7 @@ const kyc_status_1 = require("../types/kyc-status");
|
|
|
23
23
|
const missing_kyc_approval_error_1 = require("../errors/missing-kyc-approval-error");
|
|
24
24
|
const missing_user_error_1 = require("../errors/missing-user-error");
|
|
25
25
|
const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
var _a, _b;
|
|
26
|
+
var _a, _b, _c;
|
|
27
27
|
let missingKYC = false;
|
|
28
28
|
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth)) {
|
|
29
29
|
if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.jwt) {
|
|
@@ -107,13 +107,24 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
107
107
|
req.user = user;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
+
console.log("checking if user has cookies ", req.cookies);
|
|
111
|
+
if ((_c = req.cookies) === null || _c === void 0 ? void 0 : _c.jwt) {
|
|
112
|
+
console.log("kachao");
|
|
113
|
+
try {
|
|
114
|
+
const payload = jsonwebtoken_1.default.verify(req.cookies.jwt, process.env.JWT_KEY);
|
|
115
|
+
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.User) && !req.user) {
|
|
116
|
+
console.log("kachao1");
|
|
117
|
+
throw new missing_user_error_1.MissingUserError();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
console.log("kachao2");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
110
124
|
if (!req.currentAdminAuth && !req.currentAuth && !req.user) {
|
|
111
125
|
if (missingKYC) {
|
|
112
126
|
throw new missing_kyc_approval_error_1.MissingKYCApprovalError();
|
|
113
127
|
}
|
|
114
|
-
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.User) && !req.user) {
|
|
115
|
-
throw new missing_user_error_1.MissingUserError();
|
|
116
|
-
}
|
|
117
128
|
throw new not_authorized_error_1.NotAuthorizedError();
|
|
118
129
|
}
|
|
119
130
|
next();
|