@riocrypto/common 1.0.425 → 1.0.426
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.
- package/build/middlewares/get-order.js +28 -26
- package/package.json +1 -1
|
@@ -27,37 +27,39 @@ const getOrder = (req, res, next, mongoose, onlyBankOrders) => __awaiter(void 0,
|
|
|
27
27
|
else if (req.query.orderId) {
|
|
28
28
|
orderId = req.query.orderId;
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
if (orderId) {
|
|
31
|
+
try {
|
|
32
|
+
const Order = yield (0, order_1.buildOrder)(mongoose);
|
|
33
|
+
const order = yield Order.findById(orderId);
|
|
34
|
+
if (!order) {
|
|
35
|
+
throw new Error();
|
|
36
|
+
}
|
|
37
|
+
console.log("order", order.toJSON());
|
|
38
|
+
if (onlyBankOrders) {
|
|
39
|
+
if ([
|
|
40
|
+
processor_1.Processor.Interbank,
|
|
41
|
+
processor_1.Processor.SPEI,
|
|
42
|
+
processor_1.Processor.SWIFT,
|
|
43
|
+
processor_1.Processor.SPID,
|
|
44
|
+
].includes(order.processor)) {
|
|
45
|
+
req.order = order;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new wrong_processor_error_1.WrongProcessorError();
|
|
49
|
+
}
|
|
47
50
|
}
|
|
48
51
|
else {
|
|
49
|
-
|
|
52
|
+
req.order = order;
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.log(error);
|
|
57
|
+
console.log("kakakaka");
|
|
58
|
+
throw new not_found_error_1.NotFoundError();
|
|
59
|
+
}
|
|
60
|
+
if (req.order.userId !== ((_a = req.user) === null || _a === void 0 ? void 0 : _a.toJSON().id) && !req.currentAdminAuth) {
|
|
61
|
+
throw new not_authorized_error_1.NotAuthorizedError();
|
|
54
62
|
}
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
throw new not_found_error_1.NotFoundError();
|
|
58
|
-
}
|
|
59
|
-
if (req.order.userId !== ((_a = req.user) === null || _a === void 0 ? void 0 : _a.toJSON().id) && !req.currentAdminAuth) {
|
|
60
|
-
throw new not_authorized_error_1.NotAuthorizedError();
|
|
61
63
|
}
|
|
62
64
|
next();
|
|
63
65
|
});
|