@riocrypto/common 1.0.418 → 1.0.420
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.
|
@@ -59,7 +59,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
59
59
|
try {
|
|
60
60
|
const User = yield (0, user_1.buildUser)(mongoose);
|
|
61
61
|
individualUser = yield User.findOne({
|
|
62
|
-
|
|
62
|
+
authId: req.currentAuth.id,
|
|
63
63
|
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -69,7 +69,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
69
69
|
try {
|
|
70
70
|
const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
|
|
71
71
|
businessUser = yield BusinessUser.findOne({
|
|
72
|
-
|
|
72
|
+
authId: req.currentAuth.id,
|
|
73
73
|
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -87,7 +87,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
87
87
|
try {
|
|
88
88
|
const User = yield (0, user_1.buildUser)(mongoose);
|
|
89
89
|
individualUser = yield User.findOne({
|
|
90
|
-
|
|
90
|
+
authId: req.currentAuth.id,
|
|
91
91
|
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
92
92
|
});
|
|
93
93
|
if (!individualUser) {
|
|
@@ -104,7 +104,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
104
104
|
try {
|
|
105
105
|
const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
|
|
106
106
|
businessUser = yield BusinessUser.findOne({
|
|
107
|
-
|
|
107
|
+
authId: req.currentAuth.id,
|
|
108
108
|
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
109
109
|
});
|
|
110
110
|
if (!businessUser) {
|
|
@@ -124,11 +124,13 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
if ((!req.currentAdminAuth && !req.currentAuth && !req.user) ||
|
|
127
|
-
(req.currentAuth &&
|
|
127
|
+
(req.currentAuth &&
|
|
128
|
+
!authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth) &&
|
|
129
|
+
!req.user)) {
|
|
128
130
|
if (missingKYC) {
|
|
129
131
|
throw new missing_kyc_approval_error_1.MissingKYCApprovalError();
|
|
130
132
|
}
|
|
131
|
-
if ((
|
|
133
|
+
if ((authorizationTypes.includes(authorization_type_1.AuthorizationType.User) ||
|
|
132
134
|
authorizationTypes.includes(authorization_type_1.AuthorizationType.UserNoKYC)) &&
|
|
133
135
|
((_g = req.cookies) === null || _g === void 0 ? void 0 : _g.jwt)) {
|
|
134
136
|
throw new missing_user_error_1.MissingUserError();
|
package/build/models/user.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { UserAttribute } from "../types/user-attribute";
|
|
|
6
6
|
import { UserType } from "../types/user-type";
|
|
7
7
|
import { Mongoose, Model, Document } from "mongoose";
|
|
8
8
|
interface UserAttrs {
|
|
9
|
+
authId: string;
|
|
9
10
|
type: UserType;
|
|
10
11
|
firstName: string;
|
|
11
12
|
lastName: string;
|
|
@@ -29,6 +30,7 @@ interface UserModel extends Model<UserDoc> {
|
|
|
29
30
|
}
|
|
30
31
|
interface UserDoc extends Document {
|
|
31
32
|
_id: string;
|
|
33
|
+
authId: string;
|
|
32
34
|
type: UserType;
|
|
33
35
|
firstName: string;
|
|
34
36
|
lastName: string;
|
package/build/models/user.js
CHANGED