@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
package/dist/auth.server.js
CHANGED
@@ -50,6 +50,8 @@ const { verifyAppleIdToken } = verifyAppleIdToken_1;
|
|
50
50
|
const controllerFactory$3 = (db) => {
|
51
51
|
const User = db.user;
|
52
52
|
const Membership = db.membership;
|
53
|
+
const Department = db.department;
|
54
|
+
const Organization = db.organization;
|
53
55
|
const Invite = db.invite;
|
54
56
|
const Role = db.role;
|
55
57
|
const signin = async (req, res) => {
|
@@ -221,10 +223,60 @@ const controllerFactory$3 = (db) => {
|
|
221
223
|
return res.status(500).send({ message: err.message });
|
222
224
|
}
|
223
225
|
};
|
226
|
+
const checkAccesses = async (req, res) => {
|
227
|
+
try {
|
228
|
+
const uid = new db.mongoose.Types.ObjectId(req.userId);
|
229
|
+
const depts = await Department.find({ "members.user": uid });
|
230
|
+
const ownedOrgs = await Organization.find({ owner: uid });
|
231
|
+
const ownedOrgIds = ownedOrgs.map((org) => org._id.toString());
|
232
|
+
const accesses = {};
|
233
|
+
depts.forEach((dept) => {
|
234
|
+
const orgId = dept.organization.toString();
|
235
|
+
if (!accesses[orgId]) {
|
236
|
+
accesses[orgId] = {
|
237
|
+
organization: orgId,
|
238
|
+
rights: {}
|
239
|
+
};
|
240
|
+
}
|
241
|
+
const existingAccess = accesses[orgId].rights;
|
242
|
+
Object.keys(dept.accesses).forEach((key) => {
|
243
|
+
if (!existingAccess[key]) {
|
244
|
+
existingAccess[key] = {};
|
245
|
+
}
|
246
|
+
const rights = dept.accesses[key];
|
247
|
+
Object.keys(rights).forEach((right) => {
|
248
|
+
existingAccess[key][right] = existingAccess[key][right] || rights[right];
|
249
|
+
});
|
250
|
+
});
|
251
|
+
});
|
252
|
+
ownedOrgIds.forEach((orgId) => {
|
253
|
+
if (!accesses[orgId]) {
|
254
|
+
accesses[orgId] = {
|
255
|
+
organization: orgId,
|
256
|
+
rights: {}
|
257
|
+
};
|
258
|
+
}
|
259
|
+
Object.keys(depts[0].accesses).forEach((key) => {
|
260
|
+
if (!accesses[orgId].rights[key]) {
|
261
|
+
accesses[orgId].rights[key] = {};
|
262
|
+
}
|
263
|
+
Object.keys(depts[0].accesses[key]).forEach((right) => {
|
264
|
+
accesses[orgId].rights[key][right] = true;
|
265
|
+
});
|
266
|
+
});
|
267
|
+
});
|
268
|
+
const accessArray = Object.values(accesses);
|
269
|
+
res.status(200).json(accessArray);
|
270
|
+
} catch (err) {
|
271
|
+
console.error("Error getting accesses:", err);
|
272
|
+
res.status(500).json({ message: "Internal server error" });
|
273
|
+
}
|
274
|
+
};
|
224
275
|
return {
|
225
276
|
signin,
|
226
277
|
signup,
|
227
|
-
updatePassword
|
278
|
+
updatePassword,
|
279
|
+
checkAccesses
|
228
280
|
};
|
229
281
|
};
|
230
282
|
var auth_controller = controllerFactory$3;
|
@@ -263,7 +315,7 @@ const middlewareFactory$1 = index.server;
|
|
263
315
|
var auth_routes = function(app, db, origins) {
|
264
316
|
const controller = controllerFactory$1(db);
|
265
317
|
const controllerTwofa = controllerFactoryTwofa();
|
266
|
-
const { verifySignUp, verifyUser } = middlewareFactory$1(db);
|
318
|
+
const { verifySignUp, verifyUser, authJwt } = middlewareFactory$1(db);
|
267
319
|
app.post(
|
268
320
|
"/api/auth/signup",
|
269
321
|
[
|
@@ -287,6 +339,13 @@ var auth_routes = function(app, db, origins) {
|
|
287
339
|
"/api/auth/update-password",
|
288
340
|
controller.updatePassword
|
289
341
|
);
|
342
|
+
app.get(
|
343
|
+
"/api/auth/check-accesses",
|
344
|
+
[
|
345
|
+
authJwt.verifyToken
|
346
|
+
],
|
347
|
+
controller.checkAccesses
|
348
|
+
);
|
290
349
|
};
|
291
350
|
const controllerFactory = twofa_controller;
|
292
351
|
const middlewareFactory = index.server;
|
package/dist/auth.server.mjs
CHANGED
@@ -49,6 +49,8 @@ const { verifyAppleIdToken } = verifyAppleIdToken_1;
|
|
49
49
|
const controllerFactory$3 = (db) => {
|
50
50
|
const User = db.user;
|
51
51
|
const Membership = db.membership;
|
52
|
+
const Department = db.department;
|
53
|
+
const Organization = db.organization;
|
52
54
|
const Invite = db.invite;
|
53
55
|
const Role = db.role;
|
54
56
|
const signin = async (req, res) => {
|
@@ -220,10 +222,60 @@ const controllerFactory$3 = (db) => {
|
|
220
222
|
return res.status(500).send({ message: err.message });
|
221
223
|
}
|
222
224
|
};
|
225
|
+
const checkAccesses = async (req, res) => {
|
226
|
+
try {
|
227
|
+
const uid = new db.mongoose.Types.ObjectId(req.userId);
|
228
|
+
const depts = await Department.find({ "members.user": uid });
|
229
|
+
const ownedOrgs = await Organization.find({ owner: uid });
|
230
|
+
const ownedOrgIds = ownedOrgs.map((org) => org._id.toString());
|
231
|
+
const accesses = {};
|
232
|
+
depts.forEach((dept) => {
|
233
|
+
const orgId = dept.organization.toString();
|
234
|
+
if (!accesses[orgId]) {
|
235
|
+
accesses[orgId] = {
|
236
|
+
organization: orgId,
|
237
|
+
rights: {}
|
238
|
+
};
|
239
|
+
}
|
240
|
+
const existingAccess = accesses[orgId].rights;
|
241
|
+
Object.keys(dept.accesses).forEach((key) => {
|
242
|
+
if (!existingAccess[key]) {
|
243
|
+
existingAccess[key] = {};
|
244
|
+
}
|
245
|
+
const rights = dept.accesses[key];
|
246
|
+
Object.keys(rights).forEach((right) => {
|
247
|
+
existingAccess[key][right] = existingAccess[key][right] || rights[right];
|
248
|
+
});
|
249
|
+
});
|
250
|
+
});
|
251
|
+
ownedOrgIds.forEach((orgId) => {
|
252
|
+
if (!accesses[orgId]) {
|
253
|
+
accesses[orgId] = {
|
254
|
+
organization: orgId,
|
255
|
+
rights: {}
|
256
|
+
};
|
257
|
+
}
|
258
|
+
Object.keys(depts[0].accesses).forEach((key) => {
|
259
|
+
if (!accesses[orgId].rights[key]) {
|
260
|
+
accesses[orgId].rights[key] = {};
|
261
|
+
}
|
262
|
+
Object.keys(depts[0].accesses[key]).forEach((right) => {
|
263
|
+
accesses[orgId].rights[key][right] = true;
|
264
|
+
});
|
265
|
+
});
|
266
|
+
});
|
267
|
+
const accessArray = Object.values(accesses);
|
268
|
+
res.status(200).json(accessArray);
|
269
|
+
} catch (err) {
|
270
|
+
console.error("Error getting accesses:", err);
|
271
|
+
res.status(500).json({ message: "Internal server error" });
|
272
|
+
}
|
273
|
+
};
|
223
274
|
return {
|
224
275
|
signin,
|
225
276
|
signup,
|
226
|
-
updatePassword
|
277
|
+
updatePassword,
|
278
|
+
checkAccesses
|
227
279
|
};
|
228
280
|
};
|
229
281
|
var auth_controller = controllerFactory$3;
|
@@ -262,7 +314,7 @@ const middlewareFactory$1 = server;
|
|
262
314
|
var auth_routes = function(app, db, origins) {
|
263
315
|
const controller = controllerFactory$1(db);
|
264
316
|
const controllerTwofa = controllerFactoryTwofa();
|
265
|
-
const { verifySignUp, verifyUser } = middlewareFactory$1(db);
|
317
|
+
const { verifySignUp, verifyUser, authJwt } = middlewareFactory$1(db);
|
266
318
|
app.post(
|
267
319
|
"/api/auth/signup",
|
268
320
|
[
|
@@ -286,6 +338,13 @@ var auth_routes = function(app, db, origins) {
|
|
286
338
|
"/api/auth/update-password",
|
287
339
|
controller.updatePassword
|
288
340
|
);
|
341
|
+
app.get(
|
342
|
+
"/api/auth/check-accesses",
|
343
|
+
[
|
344
|
+
authJwt.verifyToken
|
345
|
+
],
|
346
|
+
controller.checkAccesses
|
347
|
+
);
|
289
348
|
};
|
290
349
|
const controllerFactory = twofa_controller;
|
291
350
|
const middlewareFactory = server;
|
package/dist/gallery.server.js
CHANGED
@@ -113,28 +113,80 @@ const controllerFactory$1 = (db) => {
|
|
113
113
|
};
|
114
114
|
};
|
115
115
|
var gallery_controller = controllerFactory$1;
|
116
|
+
const middlewareFactory = (db) => {
|
117
|
+
db.user;
|
118
|
+
const Organization = db.organization;
|
119
|
+
const Department = db.department;
|
120
|
+
const verifyRead = (resource) => {
|
121
|
+
return async (req, res, next) => {
|
122
|
+
try {
|
123
|
+
const ownerOrgId = new db.mongoose.Types.ObjectId(req.query.owner);
|
124
|
+
;
|
125
|
+
const userId = new db.mongoose.Types.ObjectId(req.userId);
|
126
|
+
const isOwnerOfOrg = await Organization.exists({
|
127
|
+
_id: ownerOrgId,
|
128
|
+
owner: userId
|
129
|
+
});
|
130
|
+
if (isOwnerOfOrg) {
|
131
|
+
return next();
|
132
|
+
}
|
133
|
+
const isMemberOfOrg = await Department.exists({
|
134
|
+
organization: ownerOrgId,
|
135
|
+
"members.user": userId
|
136
|
+
});
|
137
|
+
if (!isMemberOfOrg) {
|
138
|
+
req.query.status = "published";
|
139
|
+
} else {
|
140
|
+
const departments = await Department.find({ organization: ownerOrgId });
|
141
|
+
let hasAccess = false;
|
142
|
+
for (const department of departments) {
|
143
|
+
const accessRights = department.accesses[resource];
|
144
|
+
if (accessRights && accessRights.read) {
|
145
|
+
hasAccess = true;
|
146
|
+
break;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
if (!hasAccess) {
|
150
|
+
req.query.status = "published";
|
151
|
+
}
|
152
|
+
}
|
153
|
+
next();
|
154
|
+
} catch (err) {
|
155
|
+
console.error("Access control error:", err);
|
156
|
+
return res.status(403).json({ error: "Access denied" });
|
157
|
+
}
|
158
|
+
};
|
159
|
+
};
|
160
|
+
return {
|
161
|
+
verifyRead
|
162
|
+
};
|
163
|
+
};
|
164
|
+
var verifyAccesses = middlewareFactory;
|
116
165
|
const controllerFactory = gallery_controller;
|
117
166
|
const middlewareFactoryGlobal = index.server;
|
167
|
+
const middlewareFactoryAccesses = verifyAccesses;
|
118
168
|
var gallery_routes = function(app, db, origins) {
|
119
169
|
const controller = controllerFactory(db);
|
120
170
|
const { authJwt } = middlewareFactoryGlobal(db);
|
171
|
+
const { verifyRead } = middlewareFactoryAccesses(db);
|
121
172
|
app.get(
|
122
173
|
"/api/gallery/read",
|
174
|
+
[
|
175
|
+
authJwt.verifyToken,
|
176
|
+
verifyRead("gallery")
|
177
|
+
],
|
123
178
|
controller.read
|
124
179
|
);
|
125
180
|
app.post(
|
126
181
|
"/api/gallery/create",
|
127
|
-
[authJwt.verifyToken],
|
128
182
|
controller.create
|
129
183
|
);
|
130
184
|
app.put(
|
131
185
|
"/api/gallery/update",
|
132
|
-
[authJwt.verifyToken],
|
133
186
|
controller.update
|
134
187
|
);
|
135
188
|
app.delete(
|
136
189
|
"/api/gallery/delete/:_id",
|
137
|
-
[authJwt.verifyToken],
|
138
190
|
controller.delete
|
139
191
|
);
|
140
192
|
};
|
package/dist/gallery.server.mjs
CHANGED
@@ -112,28 +112,80 @@ const controllerFactory$1 = (db) => {
|
|
112
112
|
};
|
113
113
|
};
|
114
114
|
var gallery_controller = controllerFactory$1;
|
115
|
+
const middlewareFactory = (db) => {
|
116
|
+
db.user;
|
117
|
+
const Organization = db.organization;
|
118
|
+
const Department = db.department;
|
119
|
+
const verifyRead = (resource) => {
|
120
|
+
return async (req, res, next) => {
|
121
|
+
try {
|
122
|
+
const ownerOrgId = new db.mongoose.Types.ObjectId(req.query.owner);
|
123
|
+
;
|
124
|
+
const userId = new db.mongoose.Types.ObjectId(req.userId);
|
125
|
+
const isOwnerOfOrg = await Organization.exists({
|
126
|
+
_id: ownerOrgId,
|
127
|
+
owner: userId
|
128
|
+
});
|
129
|
+
if (isOwnerOfOrg) {
|
130
|
+
return next();
|
131
|
+
}
|
132
|
+
const isMemberOfOrg = await Department.exists({
|
133
|
+
organization: ownerOrgId,
|
134
|
+
"members.user": userId
|
135
|
+
});
|
136
|
+
if (!isMemberOfOrg) {
|
137
|
+
req.query.status = "published";
|
138
|
+
} else {
|
139
|
+
const departments = await Department.find({ organization: ownerOrgId });
|
140
|
+
let hasAccess = false;
|
141
|
+
for (const department of departments) {
|
142
|
+
const accessRights = department.accesses[resource];
|
143
|
+
if (accessRights && accessRights.read) {
|
144
|
+
hasAccess = true;
|
145
|
+
break;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
if (!hasAccess) {
|
149
|
+
req.query.status = "published";
|
150
|
+
}
|
151
|
+
}
|
152
|
+
next();
|
153
|
+
} catch (err) {
|
154
|
+
console.error("Access control error:", err);
|
155
|
+
return res.status(403).json({ error: "Access denied" });
|
156
|
+
}
|
157
|
+
};
|
158
|
+
};
|
159
|
+
return {
|
160
|
+
verifyRead
|
161
|
+
};
|
162
|
+
};
|
163
|
+
var verifyAccesses = middlewareFactory;
|
115
164
|
const controllerFactory = gallery_controller;
|
116
165
|
const middlewareFactoryGlobal = server;
|
166
|
+
const middlewareFactoryAccesses = verifyAccesses;
|
117
167
|
var gallery_routes = function(app, db, origins) {
|
118
168
|
const controller = controllerFactory(db);
|
119
169
|
const { authJwt } = middlewareFactoryGlobal(db);
|
170
|
+
const { verifyRead } = middlewareFactoryAccesses(db);
|
120
171
|
app.get(
|
121
172
|
"/api/gallery/read",
|
173
|
+
[
|
174
|
+
authJwt.verifyToken,
|
175
|
+
verifyRead("gallery")
|
176
|
+
],
|
122
177
|
controller.read
|
123
178
|
);
|
124
179
|
app.post(
|
125
180
|
"/api/gallery/create",
|
126
|
-
[authJwt.verifyToken],
|
127
181
|
controller.create
|
128
182
|
);
|
129
183
|
app.put(
|
130
184
|
"/api/gallery/update",
|
131
|
-
[authJwt.verifyToken],
|
132
185
|
controller.update
|
133
186
|
);
|
134
187
|
app.delete(
|
135
188
|
"/api/gallery/delete/:_id",
|
136
|
-
[authJwt.verifyToken],
|
137
189
|
controller.delete
|
138
190
|
);
|
139
191
|
};
|