@riocrypto/common 1.0.400 → 1.0.402

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.
@@ -30,22 +30,19 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
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);
34
- if ((_b = (_a = req.currentAuth) === null || _a === void 0 ? void 0 : _a.missing) === null || _b === void 0 ? void 0 : _b.includes("password")) {
35
- throw new missing_password_error_1.MissingPasswordError();
36
- }
37
- if ((_d = (_c = req.currentAuth) === null || _c === void 0 ? void 0 : _c.missing) === null || _d === void 0 ? void 0 : _d.includes("securityQuestion")) {
38
- throw new missing_security_question_error_1.MissingSecurityQuestionError();
39
- }
40
- }
41
- if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth)) {
42
- if ((_e = req.cookies) === null || _e === void 0 ? void 0 : _e.jwt) {
33
+ if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.jwt) {
43
34
  try {
44
35
  const payload = jsonwebtoken_1.default.verify(req.cookies.jwt, process.env.JWT_KEY);
45
36
  req.currentAuth = payload;
46
37
  }
47
38
  catch (err) { }
48
39
  }
40
+ if ((_c = (_b = req.currentAuth) === null || _b === void 0 ? void 0 : _b.missing) === null || _c === void 0 ? void 0 : _c.includes("password")) {
41
+ throw new missing_password_error_1.MissingPasswordError();
42
+ }
43
+ if ((_e = (_d = req.currentAuth) === null || _d === void 0 ? void 0 : _d.missing) === null || _e === void 0 ? void 0 : _e.includes("securityQuestion")) {
44
+ throw new missing_security_question_error_1.MissingSecurityQuestionError();
45
+ }
49
46
  }
50
47
  if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Admin)) {
51
48
  if ((_f = req.cookies) === null || _f === void 0 ? void 0 : _f.adminJwt) {
@@ -126,7 +123,8 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
126
123
  req.user = user;
127
124
  }
128
125
  }
129
- if (!req.currentAdminAuth && !req.currentAuth && !req.user) {
126
+ if ((!req.currentAdminAuth && !req.currentAuth && !req.user) ||
127
+ (req.currentAuth && !authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth))) {
130
128
  if (missingKYC) {
131
129
  throw new missing_kyc_approval_error_1.MissingKYCApprovalError();
132
130
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.400",
3
+ "version": "1.0.402",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",