@riocrypto/common 1.0.398 → 1.0.399

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,7 +25,7 @@ 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) ||
@@ -98,9 +98,6 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
98
98
  phoneNumber: req.currentAuth.phoneNumber,
99
99
  attributes: { $ne: user_attribute_1.UserAttribute.deleted },
100
100
  });
101
- if (!individualUser) {
102
- throw new missing_user_error_1.MissingUserError();
103
- }
104
101
  if ((individualUser === null || individualUser === void 0 ? void 0 : individualUser.kycStatus) !== kyc_status_1.KYCStatus.Passed) {
105
102
  missingKYC = true;
106
103
  throw new Error();
@@ -115,9 +112,6 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
115
112
  phoneNumber: req.currentAuth.phoneNumber,
116
113
  attributes: { $ne: user_attribute_1.UserAttribute.deleted },
117
114
  });
118
- if (!businessUser) {
119
- throw new missing_user_error_1.MissingUserError();
120
- }
121
115
  if ((businessUser === null || businessUser === void 0 ? void 0 : businessUser.kycStatus) !== kyc_status_1.KYCStatus.businessApproved) {
122
116
  missingKYC = true;
123
117
  throw new Error();
@@ -135,6 +129,9 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
135
129
  if (missingKYC) {
136
130
  throw new missing_kyc_approval_error_1.MissingKYCApprovalError();
137
131
  }
132
+ if ((_g = req.cookies) === null || _g === void 0 ? void 0 : _g.jwt) {
133
+ throw new missing_user_error_1.MissingUserError();
134
+ }
138
135
  throw new not_authorized_error_1.NotAuthorizedError();
139
136
  }
140
137
  next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.398",
3
+ "version": "1.0.399",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",