@riocrypto/common 1.0.398 → 1.0.400
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.
|
@@ -25,11 +25,12 @@ const missing_user_error_1 = require("../errors/missing-user-error");
|
|
|
25
25
|
const missing_password_error_1 = require("../errors/missing-password-error");
|
|
26
26
|
const missing_security_question_error_1 = require("../errors/missing-security-question-error");
|
|
27
27
|
const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
-
var _a, _b, _c, _d, _e, _f;
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
29
29
|
let missingKYC = false;
|
|
30
30
|
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth) ||
|
|
31
31
|
authorizationTypes.includes(authorization_type_1.AuthorizationType.UserNoKYC) ||
|
|
32
32
|
authorizationTypes.includes(authorization_type_1.AuthorizationType.User)) {
|
|
33
|
+
console.log(req.currentAuth);
|
|
33
34
|
if ((_b = (_a = req.currentAuth) === null || _a === void 0 ? void 0 : _a.missing) === null || _b === void 0 ? void 0 : _b.includes("password")) {
|
|
34
35
|
throw new missing_password_error_1.MissingPasswordError();
|
|
35
36
|
}
|
|
@@ -98,9 +99,6 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
98
99
|
phoneNumber: req.currentAuth.phoneNumber,
|
|
99
100
|
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
100
101
|
});
|
|
101
|
-
if (!individualUser) {
|
|
102
|
-
throw new missing_user_error_1.MissingUserError();
|
|
103
|
-
}
|
|
104
102
|
if ((individualUser === null || individualUser === void 0 ? void 0 : individualUser.kycStatus) !== kyc_status_1.KYCStatus.Passed) {
|
|
105
103
|
missingKYC = true;
|
|
106
104
|
throw new Error();
|
|
@@ -115,9 +113,6 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
115
113
|
phoneNumber: req.currentAuth.phoneNumber,
|
|
116
114
|
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
117
115
|
});
|
|
118
|
-
if (!businessUser) {
|
|
119
|
-
throw new missing_user_error_1.MissingUserError();
|
|
120
|
-
}
|
|
121
116
|
if ((businessUser === null || businessUser === void 0 ? void 0 : businessUser.kycStatus) !== kyc_status_1.KYCStatus.businessApproved) {
|
|
122
117
|
missingKYC = true;
|
|
123
118
|
throw new Error();
|
|
@@ -135,6 +130,9 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
135
130
|
if (missingKYC) {
|
|
136
131
|
throw new missing_kyc_approval_error_1.MissingKYCApprovalError();
|
|
137
132
|
}
|
|
133
|
+
if ((_g = req.cookies) === null || _g === void 0 ? void 0 : _g.jwt) {
|
|
134
|
+
throw new missing_user_error_1.MissingUserError();
|
|
135
|
+
}
|
|
138
136
|
throw new not_authorized_error_1.NotAuthorizedError();
|
|
139
137
|
}
|
|
140
138
|
next();
|