@ozdao/prometheus-framework 0.2.125 → 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-Ba3zK8PO.js +92 -0
- package/dist/main-Btlny-89.mjs +14207 -0
- 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/Dropdown/Dropdown.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue.js +58 -1
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue2.js +1 -58
- package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +67 -68
- 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/Select/Select.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Select/Select.vue.js +1 -103
- package/dist/prometheus-framework/src/components/Select/Select.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Select/Select.vue2.js +103 -1
- package/dist/prometheus-framework/src/components/Spoiler/Spoiler.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Spoiler/Spoiler.vue.js +1 -36
- package/dist/prometheus-framework/src/components/Spoiler/Spoiler.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Spoiler/Spoiler.vue2.js +36 -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/layouts/Community.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.js +1 -1
- 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 +3 -3
- 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 +4 -4
- 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 +2 -2
- 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/constructor/components/elements/Textarea.vue.cjs +1 -5
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.js +0 -66
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.cjs +5 -1
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.js +66 -0
- package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.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 +4 -4
- 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 +4 -4
- 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 +3 -3
- package/dist/prometheus-framework/src/modules/landing/components/sections/SectionGuide.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/landing/components/sections/SectionGuide.vue.js +1 -1
- 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 +4 -4
- 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 +3 -3
- 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 +2 -2
- 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/orders/components/sections/FormPayment.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.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 +15 -15
- 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/Department.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Department.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 +117 -95
- 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 +4 -4
- package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +1 -1
- 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 +3 -3
- 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 +5 -5
- 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 +2 -2
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.js +1 -1
- 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 +3 -3
- 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 +3 -3
- 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 +5 -5
- 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-CvRd3N_J.mjs +54 -0
- package/dist/web-DEysqj0n.js +1 -0
- package/dist/web-DtWmpLE-.mjs +54 -0
- package/package.json +1 -1
- package/src/components/Feed/Feed.vue +5 -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/marketplace/components/pages/Catalog.vue +1 -1
- 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
@@ -227,7 +227,6 @@ const loadMoreItems = async () => {
|
|
227
227
|
};
|
228
228
|
|
229
229
|
const fetchItems = async () => {
|
230
|
-
console.log('Date is', date.value)
|
231
230
|
const data = await props.store.read({
|
232
231
|
skip: currentSkip.value,
|
233
232
|
limit: currentLimit.value,
|
@@ -255,12 +254,14 @@ const fetchItems = async () => {
|
|
255
254
|
|
256
255
|
watch(() => props.external, (newVal, oldVal) => {
|
257
256
|
if (newVal !== oldVal) {
|
257
|
+
currentSkip.value = 0
|
258
258
|
fetchItems();
|
259
259
|
}
|
260
260
|
}, { deep: true });
|
261
261
|
|
262
262
|
watch(() => date.value, (newVal, oldVal) => {
|
263
263
|
if (newVal !== oldVal) {
|
264
|
+
currentSkip.value = 0
|
264
265
|
fetchItems();
|
265
266
|
}
|
266
267
|
}, { deep: true });
|
@@ -268,6 +269,7 @@ watch(() => date.value, (newVal, oldVal) => {
|
|
268
269
|
watch(() => sort.value?.order, (newVal, oldVal) => {
|
269
270
|
|
270
271
|
if (newVal !== oldVal) {
|
272
|
+
currentSkip.value = 0
|
271
273
|
fetchItems();
|
272
274
|
}
|
273
275
|
}, { deep: true });
|
@@ -275,6 +277,7 @@ watch(() => sort.value?.order, (newVal, oldVal) => {
|
|
275
277
|
watch(() => sort.value?.param, (newVal, oldVal) => {
|
276
278
|
|
277
279
|
if (newVal !== oldVal) {
|
280
|
+
currentSkip.value = 0
|
278
281
|
fetchItems();
|
279
282
|
}
|
280
283
|
}, { deep: true });
|
@@ -292,6 +295,7 @@ watch(() => props.options, (newVal, oldVal) => {
|
|
292
295
|
newVal.type !== oldVal.type ||
|
293
296
|
newVal.tags !== oldVal.tags
|
294
297
|
) {
|
298
|
+
currentSkip.value = 0
|
295
299
|
fetchItems();
|
296
300
|
}
|
297
301
|
}, { deep: true });
|
@@ -10,6 +10,8 @@ const controllerFactory = (db) => {
|
|
10
10
|
|
11
11
|
const User = db.user;
|
12
12
|
const Membership = db.membership;
|
13
|
+
const Department = db.department;
|
14
|
+
const Organization = db.organization;
|
13
15
|
const Invite = db.invite;
|
14
16
|
const Role = db.role;
|
15
17
|
|
@@ -146,7 +148,7 @@ const controllerFactory = (db) => {
|
|
146
148
|
|
147
149
|
const newMembership = new Membership({
|
148
150
|
type: 'organization',
|
149
|
-
|
151
|
+
user: new ObjectId(user._id),
|
150
152
|
target: new ObjectId(invite.owner.target),
|
151
153
|
role: invite.role,
|
152
154
|
label: invite.role
|
@@ -223,11 +225,75 @@ const controllerFactory = (db) => {
|
|
223
225
|
}
|
224
226
|
};
|
225
227
|
|
228
|
+
const checkAccesses = async (req, res) => {
|
229
|
+
try {
|
230
|
+
const uid = new db.mongoose.Types.ObjectId(req.userId);
|
231
|
+
const depts = await Department.find({ 'members.user': uid });
|
232
|
+
|
233
|
+
// Fetch organizations where the user is the owner
|
234
|
+
const ownedOrgs = await Organization.find({ owner: uid });
|
235
|
+
const ownedOrgIds = ownedOrgs.map(org => org._id.toString());
|
236
|
+
|
237
|
+
const accesses = {};
|
238
|
+
|
239
|
+
depts.forEach(dept => {
|
240
|
+
const orgId = dept.organization.toString();
|
241
|
+
|
242
|
+
if (!accesses[orgId]) {
|
243
|
+
accesses[orgId] = {
|
244
|
+
organization: orgId,
|
245
|
+
rights: {}
|
246
|
+
};
|
247
|
+
}
|
248
|
+
|
249
|
+
const existingAccess = accesses[orgId].rights;
|
250
|
+
|
251
|
+
Object.keys(dept.accesses).forEach(key => {
|
252
|
+
if (!existingAccess[key]) {
|
253
|
+
existingAccess[key] = {};
|
254
|
+
}
|
255
|
+
|
256
|
+
const rights = dept.accesses[key];
|
257
|
+
|
258
|
+
Object.keys(rights).forEach(right => {
|
259
|
+
existingAccess[key][right] = existingAccess[key][right] || rights[right];
|
260
|
+
});
|
261
|
+
});
|
262
|
+
});
|
263
|
+
|
264
|
+
// Grant all accesses as true if the user is the owner of the organization
|
265
|
+
ownedOrgIds.forEach(orgId => {
|
266
|
+
if (!accesses[orgId]) {
|
267
|
+
accesses[orgId] = {
|
268
|
+
organization: orgId,
|
269
|
+
rights: {}
|
270
|
+
};
|
271
|
+
}
|
272
|
+
|
273
|
+
Object.keys(depts[0].accesses).forEach(key => {
|
274
|
+
if (!accesses[orgId].rights[key]) {
|
275
|
+
accesses[orgId].rights[key] = {};
|
276
|
+
}
|
277
|
+
|
278
|
+
Object.keys(depts[0].accesses[key]).forEach(right => {
|
279
|
+
accesses[orgId].rights[key][right] = true;
|
280
|
+
});
|
281
|
+
});
|
282
|
+
});
|
283
|
+
|
284
|
+
const accessArray = Object.values(accesses);
|
285
|
+
res.status(200).json(accessArray);
|
286
|
+
} catch (err) {
|
287
|
+
console.error('Error getting accesses:', err);
|
288
|
+
res.status(500).json({ message: 'Internal server error' });
|
289
|
+
}
|
290
|
+
};
|
226
291
|
|
227
292
|
return {
|
228
293
|
signin,
|
229
294
|
signup,
|
230
|
-
updatePassword
|
295
|
+
updatePassword,
|
296
|
+
checkAccesses
|
231
297
|
};
|
232
298
|
};
|
233
299
|
|
@@ -8,7 +8,7 @@ module.exports = function(app, db, origins) {
|
|
8
8
|
const controller = controllerFactory(db);
|
9
9
|
const controllerTwofa = controllerFactoryTwofa(db);
|
10
10
|
|
11
|
-
const { verifySignUp, verifyUser } = middlewareFactory(db);
|
11
|
+
const { verifySignUp, verifyUser, authJwt } = middlewareFactory(db);
|
12
12
|
|
13
13
|
app.post(
|
14
14
|
"/api/auth/signup",
|
@@ -37,4 +37,11 @@ module.exports = function(app, db, origins) {
|
|
37
37
|
controller.updatePassword
|
38
38
|
);
|
39
39
|
|
40
|
+
app.get(
|
41
|
+
"/api/auth/check-accesses",
|
42
|
+
[
|
43
|
+
authJwt.verifyToken,
|
44
|
+
],
|
45
|
+
controller.checkAccesses
|
46
|
+
);
|
40
47
|
};
|
@@ -26,28 +26,40 @@
|
|
26
26
|
token: null,
|
27
27
|
status: false
|
28
28
|
},
|
29
|
+
accesses: [
|
30
|
+
]
|
29
31
|
});
|
30
32
|
|
31
33
|
async function initialize() {
|
32
|
-
|
34
|
+
try {
|
33
35
|
const userCookie = await getCookie('user');
|
34
36
|
|
35
37
|
if (userCookie) {
|
36
38
|
const { _id, email, phone, roles, accessToken } = userCookie;
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
$axios.interceptors.request.use((config) => {
|
42
|
-
if (accessToken) {
|
43
|
-
config.headers['x-access-token'] = accessToken;
|
44
|
-
}
|
40
|
+
// Установка токена в Axios интерцептор для всех запросов
|
41
|
+
axios.interceptors.request.use(config => {
|
42
|
+
config.headers['x-access-token'] = accessToken;
|
45
43
|
return config;
|
46
|
-
},
|
44
|
+
}, error => {
|
47
45
|
return Promise.reject(error);
|
48
46
|
});
|
47
|
+
|
48
|
+
// Проверка токена через серверный маршрут
|
49
|
+
const response = await axios.get('/api/auth/check-accesses');
|
50
|
+
const userAccesses = response.data;
|
51
|
+
|
52
|
+
// Обновление состояния приложения с информацией о пользователе и его правах доступа
|
53
|
+
Object.assign(state.user, { _id, email, phone });
|
54
|
+
Object.assign(state.access, { token: accessToken, roles, status: !!accessToken });
|
55
|
+
state.accesses = userAccesses;
|
49
56
|
}
|
57
|
+
} catch (error) {
|
58
|
+
console.error('Error initializing app:', error);
|
59
|
+
removeCookie('user');
|
60
|
+
state.accesses = [];
|
50
61
|
}
|
62
|
+
}
|
51
63
|
|
52
64
|
initialize();
|
53
65
|
|
@@ -6,6 +6,7 @@
|
|
6
6
|
class="bg-light mn-b-semi"
|
7
7
|
>
|
8
8
|
<MenuItem
|
9
|
+
v-if="hasAccess(route.params._id, 'members', 'read', auth.state.accesses)"
|
9
10
|
@click="router.push({
|
10
11
|
name: 'Organization Members',
|
11
12
|
params: {
|
@@ -34,6 +35,7 @@
|
|
34
35
|
</MenuItem> -->
|
35
36
|
|
36
37
|
<MenuItem
|
38
|
+
v-if="hasAccess(route.params._id, 'products', 'read', auth.state.accesses)"
|
37
39
|
@click="router.push({
|
38
40
|
name: 'Products',
|
39
41
|
params: {
|
@@ -48,6 +50,7 @@
|
|
48
50
|
</MenuItem>
|
49
51
|
|
50
52
|
<MenuItem
|
53
|
+
v-if="hasAccess(route.params._id, 'leftovers', 'read', auth.state.accesses)"
|
51
54
|
@click="router.push({
|
52
55
|
name: 'Leftovers',
|
53
56
|
params: {
|
@@ -62,6 +65,7 @@
|
|
62
65
|
</MenuItem>
|
63
66
|
|
64
67
|
<MenuItem
|
68
|
+
v-if="hasAccess(route.params._id, 'orders', 'read', auth.state.accesses)"
|
65
69
|
@click="router.push({
|
66
70
|
name: 'Backoffice Orders',
|
67
71
|
params: {
|
@@ -76,6 +80,7 @@
|
|
76
80
|
</MenuItem>
|
77
81
|
|
78
82
|
<MenuItem
|
83
|
+
v-if="hasAccess(route.params._id, 'gallery', 'read', auth.state.accesses)"
|
79
84
|
@click="router.push({
|
80
85
|
name: 'Backoffice Gallery',
|
81
86
|
params: {
|
@@ -90,6 +95,7 @@
|
|
90
95
|
</MenuItem>
|
91
96
|
|
92
97
|
<MenuItem
|
98
|
+
v-if="hasAccess(route.params._id, 'events', 'read', auth.state.accesses)"
|
93
99
|
@click="router.push({
|
94
100
|
name: 'Backoffice Events',
|
95
101
|
params: {
|
@@ -2,32 +2,36 @@
|
|
2
2
|
const controllerFactory = require("../controllers/gallery.controller");
|
3
3
|
// Middlewares
|
4
4
|
const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
|
5
|
+
const middlewareFactoryAccesses = require('@pf/src/modules/middlewares/server/verifyAccesses')
|
5
6
|
|
6
7
|
module.exports = function(app, db, origins) {
|
7
8
|
const controller = controllerFactory(db);
|
8
9
|
|
9
10
|
const { authJwt } = middlewareFactoryGlobal(db);
|
11
|
+
const { verifyRead } = middlewareFactoryAccesses(db)
|
12
|
+
|
10
13
|
|
11
14
|
app.get(
|
12
15
|
"/api/gallery/read",
|
16
|
+
[
|
17
|
+
authJwt.verifyToken,
|
18
|
+
verifyRead('gallery'),
|
19
|
+
],
|
13
20
|
controller.read
|
14
21
|
);
|
15
22
|
|
16
23
|
app.post(
|
17
24
|
"/api/gallery/create",
|
18
|
-
[authJwt.verifyToken],
|
19
25
|
controller.create
|
20
26
|
);
|
21
27
|
|
22
28
|
app.put(
|
23
29
|
"/api/gallery/update",
|
24
|
-
[authJwt.verifyToken],
|
25
30
|
controller.update
|
26
31
|
);
|
27
32
|
|
28
33
|
app.delete(
|
29
34
|
"/api/gallery/delete/:_id",
|
30
|
-
[authJwt.verifyToken],
|
31
35
|
controller.delete
|
32
36
|
);
|
33
37
|
};
|
@@ -1,6 +1,23 @@
|
|
1
1
|
// mixins.js
|
2
2
|
export const globalMixins = {
|
3
3
|
methods: {
|
4
|
+
hasAccess(organizationId, rightCategory, rightType, accesses) {
|
5
|
+
const accessArray = accesses;
|
6
|
+
|
7
|
+
const organizationAccess = accessArray.find(access => access.organization === organizationId);
|
8
|
+
|
9
|
+
if (!organizationAccess) {
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
|
13
|
+
const categoryAccess = organizationAccess.rights[rightCategory];
|
14
|
+
|
15
|
+
if (!categoryAccess) {
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
|
19
|
+
return categoryAccess[rightType] === true;
|
20
|
+
},
|
4
21
|
returnCurrency() {
|
5
22
|
const currency = '฿'
|
6
23
|
return currency
|
@@ -1,33 +1,110 @@
|
|
1
|
-
const
|
1
|
+
const middlewareFactory = (db) => {
|
2
|
+
const User = db.user;
|
3
|
+
const Organization = db.organization;
|
4
|
+
const Department = db.department;
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
+
const verifyRead = (resource) => {
|
7
|
+
return async (req, res, next) => {
|
8
|
+
try {
|
9
|
+
// Получаем идентификатор организации из запроса
|
10
|
+
const ownerOrgId = new db.mongoose.Types.ObjectId(req.query.owner);;
|
6
11
|
|
7
|
-
|
8
|
-
|
9
|
-
ReadDepartments,
|
10
|
-
];
|
12
|
+
// Получаем текущего пользователя
|
13
|
+
const userId = new db.mongoose.Types.ObjectId(req.userId);
|
11
14
|
|
12
|
-
|
15
|
+
// Проверяем, является ли пользователь владельцем организации
|
16
|
+
const isOwnerOfOrg = await Organization.exists({
|
17
|
+
_id: ownerOrgId,
|
18
|
+
owner: userId
|
19
|
+
});
|
13
20
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
21
|
+
// Если пользователь является владельцем организации, ему разрешен доступ ко всем ресурсам
|
22
|
+
if (isOwnerOfOrg) {
|
23
|
+
return next();
|
24
|
+
}
|
18
25
|
|
19
|
-
|
20
|
-
|
26
|
+
// Проверяем, является ли пользователь членом организации через департаменты
|
27
|
+
const isMemberOfOrg = await Department.exists({
|
28
|
+
organization: ownerOrgId,
|
29
|
+
'members.user': userId
|
30
|
+
});
|
21
31
|
|
22
|
-
// Добавляем звено следующего посредника
|
23
|
-
middleware.next = nextMiddleware;
|
24
32
|
|
25
|
-
|
26
|
-
|
33
|
+
if (!isMemberOfOrg) {
|
34
|
+
// Если пользователь не является членом организации, ограничиваем доступ к опубликованным ресурсам
|
35
|
+
req.query.status = 'published';
|
36
|
+
} else {
|
37
|
+
// Пользователь является членом организации, проверяем его права доступа
|
27
38
|
|
28
|
-
|
29
|
-
|
39
|
+
// Находим все департаменты данной организации, к которым относится пользователь
|
40
|
+
const departments = await Department.find({ organization: ownerOrgId });
|
30
41
|
|
31
|
-
|
32
|
-
|
42
|
+
// Проверяем доступ пользователя ко всем ресурсам
|
43
|
+
let hasAccess = false;
|
44
|
+
|
45
|
+
for (const department of departments) {
|
46
|
+
const accessRights = department.accesses[resource];
|
47
|
+
if (accessRights && accessRights.read) {
|
48
|
+
// Если хотя бы в одном департаменте есть права на чтение ресурса, разрешаем доступ
|
49
|
+
hasAccess = true;
|
50
|
+
break;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
if (!hasAccess) {
|
55
|
+
// Если у пользователя нет прав на чтение данного ресурса ни в одном департаменте, ограничиваем доступ к опубликованным ресурсам
|
56
|
+
req.query.status = 'published';
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
next();
|
61
|
+
} catch (err) {
|
62
|
+
console.error('Access control error:', err);
|
63
|
+
return res.status(403).json({ error: 'Access denied' });
|
64
|
+
}
|
65
|
+
};
|
66
|
+
};
|
67
|
+
|
68
|
+
// Middleware для проверки доступа
|
69
|
+
const verifyModify = (action, resource) => {
|
70
|
+
return async (req, res, next) => {
|
71
|
+
try {
|
72
|
+
const user = req.userId;
|
73
|
+
|
74
|
+
const department = await Department.findOne({
|
75
|
+
owner: organizationId
|
76
|
+
});
|
77
|
+
|
78
|
+
if (!department) {
|
79
|
+
return res.status(403).json({
|
80
|
+
message: "Access forbidden"
|
81
|
+
});
|
82
|
+
}
|
83
|
+
|
84
|
+
const accesses = department.accesses;
|
85
|
+
|
86
|
+
// Проверяем права доступа пользователя к ресурсу
|
87
|
+
const resourceAccess = accesses[resource];
|
88
|
+
if (!resourceAccess || !resourceAccess[action]) {
|
89
|
+
return res.status(403).json({
|
90
|
+
message: "Access forbidden"
|
91
|
+
});
|
92
|
+
}
|
93
|
+
|
94
|
+
next();
|
95
|
+
} catch (error) {
|
96
|
+
console.error("Access control error:", error);
|
97
|
+
return res.status(500).json({
|
98
|
+
message: "Internal server error"
|
99
|
+
});
|
100
|
+
}
|
101
|
+
};
|
102
|
+
};
|
103
|
+
|
104
|
+
|
105
|
+
return {
|
106
|
+
verifyRead,
|
107
|
+
};
|
33
108
|
};
|
109
|
+
|
110
|
+
module.exports = middlewareFactory;
|
@@ -32,7 +32,7 @@
|
|
32
32
|
<ul>
|
33
33
|
<li v-if="department.members.length < 1">No members in department</li>
|
34
34
|
<User
|
35
|
-
class="pd-small br-solid br-1px br-black-transp-5 radius-small mn-b-thin"
|
35
|
+
class="h-4r pd-small br-solid br-1px br-black-transp-5 radius-small mn-b-thin"
|
36
36
|
v-for="(member, index) in department.members"
|
37
37
|
:key="index"
|
38
38
|
:user="member.user"
|
@@ -54,7 +54,7 @@
|
|
54
54
|
class="cols-1 gap-thin mn-b-thin"
|
55
55
|
>
|
56
56
|
<CardUser
|
57
|
-
class="bg-white pd-thin radius-medium w-100"
|
57
|
+
class="h-4r bg-white pd-thin radius-medium w-100"
|
58
58
|
v-for="(member, index) in departments.state.department.members"
|
59
59
|
:key="index"
|
60
60
|
:user="member.user"
|
@@ -110,7 +110,7 @@
|
|
110
110
|
globals.actions.add(departments.state.department.members, { _id: user.user._id, user: user.user, position: 'Member'})
|
111
111
|
closeMemberPopup();
|
112
112
|
}"
|
113
|
-
class="bg-white pd-thin radius-medium w-100 mn-b-thin"
|
113
|
+
class="h-4r bg-white pd-thin radius-medium w-100 mn-b-thin"
|
114
114
|
/>
|
115
115
|
</Feed>
|
116
116
|
</Popup>
|
@@ -139,6 +139,28 @@
|
|
139
139
|
<p class="p-medium mn-b-small">Please select organization accesses for user in department:</p>
|
140
140
|
|
141
141
|
<div class="cols-1 gap-thin">
|
142
|
+
<h4>Gallery</h4>
|
143
|
+
<Checkbox
|
144
|
+
label="Read gallery"
|
145
|
+
name="readProducts"
|
146
|
+
class="w-100 mn-r-small bg-white radius-small pd-small"
|
147
|
+
:radio="departments.state.department.accesses.gallery.read"
|
148
|
+
@update:radio="updated => (departments.state.department.accesses.gallery.read = !departments.state.department.accesses.gallery.read)"
|
149
|
+
/>
|
150
|
+
<Checkbox
|
151
|
+
label="Edit gallery"
|
152
|
+
name="editProducts"
|
153
|
+
class="w-100 mn-r-small bg-white radius-small pd-small"
|
154
|
+
:radio="departments.state.department.accesses.gallery.edit"
|
155
|
+
@update:radio="updated => (departments.state.department.accesses.gallery.edit = !departments.state.department.accesses.gallery.edit)"
|
156
|
+
/>
|
157
|
+
<Checkbox
|
158
|
+
label="Delete gallery"
|
159
|
+
name="deleteProducts"
|
160
|
+
class="w-100 bg-white radius-small pd-small"
|
161
|
+
:radio="departments.state.department.accesses.gallery.delete"
|
162
|
+
@update:radio="updated => (departments.state.department.accesses.gallery.delete = !departments.state.department.accesses.gallery.delete)"
|
163
|
+
/>
|
142
164
|
<h4>Products</h4>
|
143
165
|
<Checkbox
|
144
166
|
label="Read products"
|
@@ -28,6 +28,48 @@ module.exports = (mongoose) => {
|
|
28
28
|
},
|
29
29
|
|
30
30
|
accesses: {
|
31
|
+
members: {
|
32
|
+
read: {
|
33
|
+
type: Boolean,
|
34
|
+
default: false,
|
35
|
+
},
|
36
|
+
edit: {
|
37
|
+
type: Boolean,
|
38
|
+
default: false,
|
39
|
+
},
|
40
|
+
delete: {
|
41
|
+
type: Boolean,
|
42
|
+
default: false,
|
43
|
+
},
|
44
|
+
},
|
45
|
+
gallery: {
|
46
|
+
read: {
|
47
|
+
type: Boolean,
|
48
|
+
default: false,
|
49
|
+
},
|
50
|
+
edit: {
|
51
|
+
type: Boolean,
|
52
|
+
default: false,
|
53
|
+
},
|
54
|
+
delete: {
|
55
|
+
type: Boolean,
|
56
|
+
default: false,
|
57
|
+
},
|
58
|
+
},
|
59
|
+
leftovers: {
|
60
|
+
read: {
|
61
|
+
type: Boolean,
|
62
|
+
default: false,
|
63
|
+
},
|
64
|
+
edit: {
|
65
|
+
type: Boolean,
|
66
|
+
default: false,
|
67
|
+
},
|
68
|
+
delete: {
|
69
|
+
type: Boolean,
|
70
|
+
default: false,
|
71
|
+
},
|
72
|
+
},
|
31
73
|
products: {
|
32
74
|
read: {
|
33
75
|
type: Boolean,
|
@@ -42,7 +84,6 @@ module.exports = (mongoose) => {
|
|
42
84
|
default: false,
|
43
85
|
},
|
44
86
|
},
|
45
|
-
|
46
87
|
orders: {
|
47
88
|
read: {
|
48
89
|
type: Boolean,
|
@@ -57,7 +98,6 @@ module.exports = (mongoose) => {
|
|
57
98
|
default: false,
|
58
99
|
},
|
59
100
|
},
|
60
|
-
|
61
101
|
departments: {
|
62
102
|
read: {
|
63
103
|
type: Boolean,
|
@@ -1,19 +1,12 @@
|
|
1
1
|
// Factories
|
2
2
|
const controllerFactory = require("../controllers/departments.controller")
|
3
|
-
// Middlewares
|
4
|
-
const accessMiddlewaresFactory = require('@pf/src/modules/middlewares/server/verifyAccesses')
|
5
|
-
|
6
3
|
// Routes
|
7
4
|
module.exports = function(app, db) {
|
8
5
|
const controller = controllerFactory(db)
|
9
|
-
|
10
|
-
|
6
|
+
|
11
7
|
// Get organization departments by _id
|
12
8
|
app.get(
|
13
9
|
"/api/departments/read",
|
14
|
-
// [
|
15
|
-
// verifyAccesses('read', 'departments'),
|
16
|
-
// ],
|
17
10
|
controller.read
|
18
11
|
);
|
19
12
|
|