@ozdao/prometheus-framework 0.2.126 → 0.2.127
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth.server.js +61 -2
- package/dist/auth.server.mjs +61 -2
- package/dist/gallery.server.js +55 -3
- package/dist/gallery.server.mjs +55 -3
- package/dist/main-CF35oB7q.js +92 -0
- package/dist/main-CmL_j3wv.mjs +14223 -0
- package/dist/organizations.server.js +112 -184
- package/dist/organizations.server.mjs +112 -184
- package/dist/prometheus-framework/src/components/Block/Block.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Block/Block.vue.js +1 -1
- package/dist/prometheus-framework/src/components/Button/Button.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Button/Button.vue.js +1 -94
- package/dist/prometheus-framework/src/components/Button/Button.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Button/Button.vue2.js +94 -1
- package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Field/Field.vue.js +1 -84
- package/dist/prometheus-framework/src/components/Field/Field.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Field/Field.vue2.js +84 -1
- package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.js +1 -1
- package/dist/prometheus-framework/src/components/Popup/Popup.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Popup/Popup.vue.js +1 -77
- package/dist/prometheus-framework/src/components/Popup/Popup.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Popup/Popup.vue2.js +77 -1
- package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue.js +1 -45
- package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue2.js +45 -1
- package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/auth/store/auth.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/store/auth.js +57 -50
- package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +68 -62
- package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/gallery/components/pages/Gallery.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/pages/Gallery.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/gallery/gallery.client.cjs +1 -1
- package/dist/prometheus-framework/src/modules/gallery/gallery.client.js +4 -4
- package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.js +14 -14
- package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +116 -94
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/organizations/store/departments.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/store/departments.js +9 -4
- package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +3 -3
- package/dist/prometheus-framework.cjs.js +1 -1
- package/dist/prometheus-framework.es.js +1 -1
- package/dist/style.css +1 -1
- package/dist/web-BDaOF322.js +1 -0
- package/dist/web-DtWmpLE-.mjs +54 -0
- package/package.json +1 -1
- package/src/modules/auth/controllers/auth.controller.js +68 -2
- package/src/modules/auth/routes/auth.routes.js +8 -1
- package/src/modules/auth/store/auth.js +21 -9
- package/src/modules/backoffice/components/pages/Dashboard.vue +6 -0
- package/src/modules/gallery/gallery.client.js +1 -1
- package/src/modules/gallery/routes/gallery.routes.js +7 -3
- package/src/modules/globals/mixins/mixins.js +17 -0
- package/src/modules/middlewares/server/verifyAccesses.js +100 -23
- package/src/modules/organizations/components/blocks/CardDepartment.vue +1 -1
- package/src/modules/organizations/components/pages/DepartmentEdit.vue +24 -2
- package/src/modules/organizations/components/pages/Members.vue +1 -1
- package/src/modules/organizations/models/department.model.js +42 -2
- package/src/modules/organizations/routes/departments.routes.js +1 -8
- package/src/modules/organizations/store/departments.js +5 -0
@@ -15,17 +15,17 @@ const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
|
|
15
15
|
const credentials_schema = require("./credentials.schema-B-KD_ozQ.js");
|
16
16
|
const controllerFactory$6 = (db) => {
|
17
17
|
const Department = db.department;
|
18
|
-
const readOne = (req,
|
18
|
+
const readOne = (req, res) => {
|
19
19
|
Department.findOne({ _id: req.params._id }).populate("members.user").populate("subdepartments").then((department) => {
|
20
20
|
if (!department) {
|
21
|
-
return
|
21
|
+
return res.status(404).send({ message: "Отдел не найден" });
|
22
22
|
}
|
23
|
-
|
23
|
+
res.send(department);
|
24
24
|
}).catch((err) => {
|
25
|
-
|
25
|
+
res.status(500).send({ message: err.message });
|
26
26
|
});
|
27
27
|
};
|
28
|
-
const read = (req,
|
28
|
+
const read = (req, res) => {
|
29
29
|
let query = {};
|
30
30
|
let options = {};
|
31
31
|
if (req.query.organization) {
|
@@ -36,43 +36,43 @@ const controllerFactory$6 = (db) => {
|
|
36
36
|
}
|
37
37
|
Department.find(query, null, options).populate("members.user").populate("subdepartments").then((departments) => {
|
38
38
|
if (!departments) {
|
39
|
-
return
|
39
|
+
return res.status(404).send({ message: "Departments not found" });
|
40
40
|
}
|
41
|
-
|
41
|
+
res.send(departments);
|
42
42
|
}).catch((err) => {
|
43
|
-
|
43
|
+
res.status(500).send({ message: err.message });
|
44
44
|
});
|
45
45
|
};
|
46
|
-
const create = async (req,
|
46
|
+
const create = async (req, res) => {
|
47
47
|
try {
|
48
48
|
const newDepartment = new Department({
|
49
49
|
...req.body,
|
50
50
|
organization: req.params._id
|
51
51
|
});
|
52
52
|
const data = await newDepartment.save();
|
53
|
-
|
53
|
+
res.send(data);
|
54
54
|
} catch (err) {
|
55
|
-
|
55
|
+
res.status(500).send({ message: err.message });
|
56
56
|
}
|
57
57
|
};
|
58
|
-
const update = (req,
|
58
|
+
const update = (req, res) => {
|
59
59
|
Department.findOneAndUpdate({ _id: req.body._id }, req.body, { new: true }).then((department) => {
|
60
60
|
if (!department) {
|
61
|
-
return
|
61
|
+
return res.status(404).send({ message: "Department not found" });
|
62
62
|
}
|
63
|
-
|
63
|
+
res.send(department);
|
64
64
|
}).catch((err) => {
|
65
|
-
|
65
|
+
res.status(500).send({ message: err.message });
|
66
66
|
});
|
67
67
|
};
|
68
|
-
const deleteDepartment = (req,
|
68
|
+
const deleteDepartment = (req, res) => {
|
69
69
|
Department.findOneAndRemove({ _id: req.body._id, organization: req.params._id }).then((department) => {
|
70
70
|
if (!department) {
|
71
|
-
return
|
71
|
+
return res.status(404).send({ message: "Department not found" });
|
72
72
|
}
|
73
|
-
|
73
|
+
res.send({ message: "Department deleted successfully" });
|
74
74
|
}).catch((err) => {
|
75
|
-
|
75
|
+
res.status(500).send({ message: err.message });
|
76
76
|
});
|
77
77
|
};
|
78
78
|
return {
|
@@ -95,7 +95,7 @@ const controllerFactory$5 = (db) => {
|
|
95
95
|
const Membership = db.membership;
|
96
96
|
db.user;
|
97
97
|
db.role;
|
98
|
-
const read = async (req,
|
98
|
+
const read = async (req, res) => {
|
99
99
|
const sortParam = req.query.sortParam || "numberOfProducts";
|
100
100
|
const sortOrder = req.query.sortOrder || "desc";
|
101
101
|
const sort = {
|
@@ -175,11 +175,11 @@ const controllerFactory$5 = (db) => {
|
|
175
175
|
];
|
176
176
|
console.log(userLocation);
|
177
177
|
} else {
|
178
|
-
return
|
178
|
+
return res.status(400).send({ message: "Unable to geocode the provided location." });
|
179
179
|
}
|
180
180
|
} catch (err) {
|
181
181
|
console.log(err);
|
182
|
-
return
|
182
|
+
return res.status(500).send({ message: "Error occurred while geocoding." });
|
183
183
|
}
|
184
184
|
const radius = city ? 500 : state ? 1e3 : 5e3;
|
185
185
|
matchConditions.push({
|
@@ -349,13 +349,13 @@ const controllerFactory$5 = (db) => {
|
|
349
349
|
try {
|
350
350
|
console.log(stages);
|
351
351
|
const organizations = await Organization.aggregate(stages);
|
352
|
-
|
352
|
+
res.status(200).send(organizations);
|
353
353
|
} catch (err) {
|
354
354
|
console.log(err);
|
355
|
-
return
|
355
|
+
return res.status(500).send({ message: err });
|
356
356
|
}
|
357
357
|
};
|
358
|
-
const fetch = async (req,
|
358
|
+
const fetch = async (req, res) => {
|
359
359
|
const Organization2 = db.organization;
|
360
360
|
let query = {};
|
361
361
|
console.log(req.query);
|
@@ -374,14 +374,14 @@ const controllerFactory$5 = (db) => {
|
|
374
374
|
try {
|
375
375
|
const organizations = await Organization2.find(query, null, options);
|
376
376
|
if (!organizations || organizations.length === 0) {
|
377
|
-
return
|
377
|
+
return res.status(404).send({ message: "Organizations not found." });
|
378
378
|
}
|
379
|
-
|
379
|
+
res.status(200).send(organizations);
|
380
380
|
} catch (err) {
|
381
|
-
return
|
381
|
+
return res.status(500).send({ message: err });
|
382
382
|
}
|
383
383
|
};
|
384
|
-
const create = async (req,
|
384
|
+
const create = async (req, res) => {
|
385
385
|
if (req.body._id === null) {
|
386
386
|
delete req.body._id;
|
387
387
|
}
|
@@ -396,13 +396,13 @@ const controllerFactory$5 = (db) => {
|
|
396
396
|
label: "owner"
|
397
397
|
});
|
398
398
|
const savedMembership = await membership.save();
|
399
|
-
|
399
|
+
res.status(201).json(savedOrganization);
|
400
400
|
} catch (error) {
|
401
401
|
console.error("Error:", error);
|
402
|
-
|
402
|
+
res.status(500).send(error);
|
403
403
|
}
|
404
404
|
};
|
405
|
-
const update = async (req,
|
405
|
+
const update = async (req, res) => {
|
406
406
|
try {
|
407
407
|
const organizationId = req.params._id;
|
408
408
|
const updatedData = req.body;
|
@@ -411,17 +411,17 @@ const controllerFactory$5 = (db) => {
|
|
411
411
|
runValidators: true
|
412
412
|
});
|
413
413
|
if (!organization) {
|
414
|
-
return
|
414
|
+
return res.status(404).json({ message: "Organization not found" });
|
415
415
|
}
|
416
|
-
|
416
|
+
res.status(200).json({ message: "Organization updated successfully", organization });
|
417
417
|
} catch (error) {
|
418
|
-
|
418
|
+
res.status(500).json({ error: error.message });
|
419
419
|
}
|
420
420
|
};
|
421
|
-
const deleteOrganization = async (req,
|
421
|
+
const deleteOrganization = async (req, res) => {
|
422
422
|
Organization.findOneAndRemove({ _id: req.params._id }).then((organization) => {
|
423
423
|
if (!organization) {
|
424
|
-
return
|
424
|
+
return res.status(404).send({ message: "Organization not found" });
|
425
425
|
}
|
426
426
|
Membership.deleteMany({ target: req.params._id }).then(() => {
|
427
427
|
const newToken = jwt.sign({
|
@@ -431,12 +431,12 @@ const controllerFactory$5 = (db) => {
|
|
431
431
|
expiresIn: 86400
|
432
432
|
// 24 hours
|
433
433
|
});
|
434
|
-
|
434
|
+
res.send({ newToken });
|
435
435
|
}).catch((err) => {
|
436
|
-
|
436
|
+
res.status(500).send({ message: "Error deleting memberships: " + err.message });
|
437
437
|
});
|
438
438
|
}).catch((err) => {
|
439
|
-
|
439
|
+
res.status(500).send({ message: err.message });
|
440
440
|
});
|
441
441
|
};
|
442
442
|
return {
|
@@ -453,7 +453,7 @@ const ObjectId = require$$0.Types.ObjectId;
|
|
453
453
|
const queryProcessorGlobals = queryProcessor.queryProcessor;
|
454
454
|
const controllerFactory$4 = (db) => {
|
455
455
|
const Membership = db.membership;
|
456
|
-
const read = async (req,
|
456
|
+
const read = async (req, res) => {
|
457
457
|
try {
|
458
458
|
let search = req.query.search;
|
459
459
|
let regexPattern = "";
|
@@ -504,16 +504,16 @@ const controllerFactory$4 = (db) => {
|
|
504
504
|
)
|
505
505
|
]);
|
506
506
|
if (!memberships || memberships.length === 0) {
|
507
|
-
return
|
507
|
+
return res.status(404).send({ errorCode: "MEMBERSHIPS_NOT_FOUND" });
|
508
508
|
}
|
509
509
|
console.log("membership is", memberships[0].user);
|
510
|
-
|
510
|
+
res.send(memberships);
|
511
511
|
} catch (err) {
|
512
512
|
console.log(err);
|
513
|
-
|
513
|
+
res.status(500).send({ errorCode: "SERVER_ERROR" });
|
514
514
|
}
|
515
515
|
};
|
516
|
-
const create = async (req,
|
516
|
+
const create = async (req, res) => {
|
517
517
|
const newMembership = new Membership({
|
518
518
|
user: req.body.user,
|
519
519
|
type: req.body.type,
|
@@ -522,35 +522,35 @@ const controllerFactory$4 = (db) => {
|
|
522
522
|
});
|
523
523
|
try {
|
524
524
|
const data = await newMembership.save();
|
525
|
-
|
525
|
+
res.send(data);
|
526
526
|
} catch (err) {
|
527
|
-
|
527
|
+
res.status(500).send({ errorCode: "SERVER_ERROR" });
|
528
528
|
}
|
529
529
|
};
|
530
|
-
const update = async (req,
|
530
|
+
const update = async (req, res) => {
|
531
531
|
try {
|
532
532
|
const membership = await Membership.findByIdAndUpdate(req.body._id, req.body, { new: true });
|
533
533
|
if (!membership) {
|
534
|
-
return
|
534
|
+
return res.status(404).send({ errorCode: "MEMBERSHIP_NOT_FOUND" });
|
535
535
|
}
|
536
|
-
|
536
|
+
res.send(membership);
|
537
537
|
} catch (err) {
|
538
|
-
|
538
|
+
res.status(500).send({ errorCode: "SERVER_ERROR" });
|
539
539
|
}
|
540
540
|
};
|
541
|
-
const deleteMembership = async (req,
|
541
|
+
const deleteMembership = async (req, res) => {
|
542
542
|
console.log(req.body);
|
543
543
|
try {
|
544
544
|
const membership = await Membership.findOneAndDelete({ _id: new ObjectId(req.body._id) });
|
545
545
|
if (!membership) {
|
546
|
-
return
|
546
|
+
return res.status(404).send({ errorCode: "MEMBERSHIP_NOT_FOUND" });
|
547
547
|
} else {
|
548
548
|
await Membership.deleteOne({ _id: membership._id });
|
549
|
-
|
549
|
+
res.status(200).send(membership);
|
550
550
|
}
|
551
551
|
} catch (error) {
|
552
552
|
console.log(error);
|
553
|
-
|
553
|
+
res.status(500).send({ errorCode: "SERVER_ERROR" });
|
554
554
|
}
|
555
555
|
};
|
556
556
|
return {
|
@@ -567,29 +567,29 @@ const сontrollerFactory = (db) => {
|
|
567
567
|
const User = db.user;
|
568
568
|
const Invite = db.invite;
|
569
569
|
const Membership = db.membership;
|
570
|
-
const getOneByCode = async (req,
|
570
|
+
const getOneByCode = async (req, res) => {
|
571
571
|
try {
|
572
572
|
const invite = await Invite.findOne({ code: req.params._id });
|
573
573
|
if (!invite) {
|
574
|
-
return
|
574
|
+
return res.status(404).send({ message: "Приглашение не найдено" });
|
575
575
|
}
|
576
|
-
|
576
|
+
res.send(invite);
|
577
577
|
} catch (err) {
|
578
|
-
|
578
|
+
res.status(500).send({ message: err.message });
|
579
579
|
}
|
580
580
|
};
|
581
|
-
const read = async (req,
|
581
|
+
const read = async (req, res) => {
|
582
582
|
try {
|
583
583
|
const invites = await Invite.find({ "owner.target": req.params._id });
|
584
584
|
if (!invites || invites.length === 0) {
|
585
|
-
return
|
585
|
+
return res.status(200).send([]);
|
586
586
|
}
|
587
|
-
|
587
|
+
res.send(invites);
|
588
588
|
} catch (err) {
|
589
|
-
|
589
|
+
res.status(500).send({ message: err.message });
|
590
590
|
}
|
591
591
|
};
|
592
|
-
const create = async (req,
|
592
|
+
const create = async (req, res) => {
|
593
593
|
const creator = req.body.creator;
|
594
594
|
const owner = req.body.owner;
|
595
595
|
const list = req.body.invites;
|
@@ -633,21 +633,21 @@ const сontrollerFactory = (db) => {
|
|
633
633
|
}
|
634
634
|
}
|
635
635
|
}
|
636
|
-
|
636
|
+
res.status(200).json({ message: "Invites sent successfully!" });
|
637
637
|
} catch (error) {
|
638
638
|
console.error(error);
|
639
|
-
|
639
|
+
res.status(500).json({ message: "Something went wrong" });
|
640
640
|
}
|
641
641
|
};
|
642
|
-
const deleteInvite = async (req,
|
642
|
+
const deleteInvite = async (req, res) => {
|
643
643
|
try {
|
644
644
|
const invite = await Invite.findOneAndDelete({ _id: req.params._id });
|
645
645
|
if (!invite) {
|
646
|
-
return
|
646
|
+
return res.status(404).send({ message: "Invite not found" });
|
647
647
|
}
|
648
|
-
|
648
|
+
res.send({ message: "Invite deleted successfully" });
|
649
649
|
} catch (err) {
|
650
|
-
|
650
|
+
res.status(500).send({ message: err.message });
|
651
651
|
}
|
652
652
|
};
|
653
653
|
return {
|
@@ -658,125 +658,11 @@ const сontrollerFactory = (db) => {
|
|
658
658
|
};
|
659
659
|
};
|
660
660
|
var invites_controller = сontrollerFactory;
|
661
|
-
let AccessController$1 = class AccessController {
|
662
|
-
db = null;
|
663
|
-
rule = null;
|
664
|
-
next = null;
|
665
|
-
entity = null;
|
666
|
-
/**
|
667
|
-
* @param {String} rule - Права на проверку (read, create, ...)
|
668
|
-
* @param {String} entity - Сущность на проверку (departments, post, ...)
|
669
|
-
*/
|
670
|
-
check(rule, entity) {
|
671
|
-
if (this.rule === rule && this.entity === entity) {
|
672
|
-
return this.access.bind(this);
|
673
|
-
} else if (this.next) {
|
674
|
-
this.next.check(rule, entity);
|
675
|
-
} else {
|
676
|
-
console.error("Неудачная попытка вызова посредника verifyAccesses");
|
677
|
-
console.error("Переданные аргументы:", this.rule, this.entity);
|
678
|
-
return async (req, res2, next) => {
|
679
|
-
return res2.status(403).send({ message: "Access Denied. Middleware not founded" });
|
680
|
-
};
|
681
|
-
}
|
682
|
-
}
|
683
|
-
};
|
684
|
-
var AccessController_1 = AccessController$1;
|
685
|
-
const AccessController2 = AccessController_1;
|
686
|
-
let ReadDepartments$1 = class ReadDepartments extends AccessController2 {
|
687
|
-
rule = "read";
|
688
|
-
entity = "departments";
|
689
|
-
async access(req, res2, next) {
|
690
|
-
const Department = this.db.department;
|
691
|
-
try {
|
692
|
-
const userId = req.cookies.user._id;
|
693
|
-
const organization = req.query.organization;
|
694
|
-
const departments = await Department.find({
|
695
|
-
organization: { $eq: organization },
|
696
|
-
members: { $elemMatch: { user: userId } }
|
697
|
-
});
|
698
|
-
if (!departments.length) {
|
699
|
-
return res2.status(403).send({
|
700
|
-
message: "Access Denied. Read Departments. Департаменты не найдены"
|
701
|
-
});
|
702
|
-
}
|
703
|
-
let hasAccess = false;
|
704
|
-
departments.forEach((departament) => {
|
705
|
-
const accesses = departament.accesses;
|
706
|
-
if (getNestedProperty(accesses, rulePath)) {
|
707
|
-
hasAccess = true;
|
708
|
-
}
|
709
|
-
});
|
710
|
-
if (hasAccess) {
|
711
|
-
next();
|
712
|
-
} else {
|
713
|
-
return res2.status(403).send({ message: "Access Denied. Read Departments. No access" });
|
714
|
-
}
|
715
|
-
} catch (error) {
|
716
|
-
console.error("[canReadDepartments]", error);
|
717
|
-
return res2.status(500).send({ message: error.message });
|
718
|
-
}
|
719
|
-
}
|
720
|
-
/**
|
721
|
-
* // note: пока не использовался метод
|
722
|
-
* @param {Object} req объект
|
723
|
-
* @returns
|
724
|
-
*/
|
725
|
-
async departmentsWhereUserIsMember(req) {
|
726
|
-
const Department = this.db.department;
|
727
|
-
try {
|
728
|
-
const userId = req.cookies.user._id;
|
729
|
-
const organization = req.query.organization;
|
730
|
-
const departments = await Department.find({
|
731
|
-
organization: { $eq: organization },
|
732
|
-
members: { $elemMatch: { user: userId } }
|
733
|
-
});
|
734
|
-
return departments;
|
735
|
-
} catch (error) {
|
736
|
-
console.error("[canReadDepartments]", error);
|
737
|
-
return res.status(500).send({ message: error.message });
|
738
|
-
}
|
739
|
-
}
|
740
|
-
};
|
741
|
-
var ReadDepartments_1 = ReadDepartments$1;
|
742
|
-
function getNestedProperty(obj, propertyPath) {
|
743
|
-
const properties = propertyPath.split(".");
|
744
|
-
let value = obj;
|
745
|
-
for (const property of properties) {
|
746
|
-
if (!value.hasOwnProperty(property)) {
|
747
|
-
return void 0;
|
748
|
-
}
|
749
|
-
value = value[property];
|
750
|
-
}
|
751
|
-
return value;
|
752
|
-
}
|
753
|
-
const ReadDepartments2 = ReadDepartments_1;
|
754
|
-
var verifyAccesses = (db) => {
|
755
|
-
const instances = [];
|
756
|
-
const middlewares = [
|
757
|
-
ReadDepartments2
|
758
|
-
];
|
759
|
-
let nextMiddleware = null;
|
760
|
-
for (let i = middlewares.length - 1; i >= 0; i--) {
|
761
|
-
const Middleware = middlewares[i];
|
762
|
-
const middleware = new Middleware();
|
763
|
-
middleware.db = db;
|
764
|
-
middleware.next = nextMiddleware;
|
765
|
-
instances.unshift(middleware);
|
766
|
-
nextMiddleware = middleware;
|
767
|
-
}
|
768
|
-
return (rule, entity) => instances[0].check(rule, entity);
|
769
|
-
};
|
770
661
|
const controllerFactory$3 = departments_controller;
|
771
|
-
const accessMiddlewaresFactory = verifyAccesses;
|
772
662
|
var departments_routes = function(app, db) {
|
773
663
|
const controller = controllerFactory$3(db);
|
774
|
-
accessMiddlewaresFactory(db);
|
775
664
|
app.get(
|
776
665
|
"/api/departments/read",
|
777
|
-
// [
|
778
|
-
// verifyAccesses('read', 'departments'),
|
779
|
-
// ],
|
780
666
|
controller.read
|
781
667
|
);
|
782
668
|
app.get("/api/departments/get/:_id", controller.readOne);
|
@@ -878,6 +764,48 @@ var department_model = (mongoose) => {
|
|
878
764
|
default: false
|
879
765
|
},
|
880
766
|
accesses: {
|
767
|
+
members: {
|
768
|
+
read: {
|
769
|
+
type: Boolean,
|
770
|
+
default: false
|
771
|
+
},
|
772
|
+
edit: {
|
773
|
+
type: Boolean,
|
774
|
+
default: false
|
775
|
+
},
|
776
|
+
delete: {
|
777
|
+
type: Boolean,
|
778
|
+
default: false
|
779
|
+
}
|
780
|
+
},
|
781
|
+
gallery: {
|
782
|
+
read: {
|
783
|
+
type: Boolean,
|
784
|
+
default: false
|
785
|
+
},
|
786
|
+
edit: {
|
787
|
+
type: Boolean,
|
788
|
+
default: false
|
789
|
+
},
|
790
|
+
delete: {
|
791
|
+
type: Boolean,
|
792
|
+
default: false
|
793
|
+
}
|
794
|
+
},
|
795
|
+
leftovers: {
|
796
|
+
read: {
|
797
|
+
type: Boolean,
|
798
|
+
default: false
|
799
|
+
},
|
800
|
+
edit: {
|
801
|
+
type: Boolean,
|
802
|
+
default: false
|
803
|
+
},
|
804
|
+
delete: {
|
805
|
+
type: Boolean,
|
806
|
+
default: false
|
807
|
+
}
|
808
|
+
},
|
881
809
|
products: {
|
882
810
|
read: {
|
883
811
|
type: Boolean,
|