@ozdao/prometheus-framework 0.2.138 → 0.2.140
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth.server.js +30 -15
- package/dist/auth.server.mjs +30 -15
- package/dist/community.server.js +3 -3
- package/dist/community.server.mjs +3 -3
- package/dist/events.server.js +3 -3
- package/dist/events.server.mjs +3 -3
- package/dist/files.server.js +3 -3
- package/dist/files.server.mjs +3 -3
- package/dist/gallery.server.js +4 -4
- package/dist/gallery.server.mjs +4 -4
- package/dist/index-DNI4aUP2.js +259 -0
- package/dist/index-Tcyehi73.mjs +260 -0
- package/dist/orders.server.js +9 -8
- package/dist/orders.server.mjs +9 -8
- package/dist/organizations.server.js +31 -15
- package/dist/organizations.server.mjs +31 -15
- package/dist/products.server.js +37 -5
- package/dist/products.server.mjs +37 -5
- package/dist/prometheus-framework/src/components/Completion/Completion.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Completion/Completion.vue.js +19 -19
- package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +1 -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/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 +32 -31
- 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 +50 -47
- package/dist/prometheus-framework/src/modules/community/components/blocks/CardBlogpost.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/blocks/CardBlogpost.vue.js +1 -1
- 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 +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 +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/events/components/blocks/CardEvent.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/blocks/CardEvent.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 +2 -2
- 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 +5 -5
- 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/marketplace/store/marketplace.cjs +1 -1
- package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.js +1 -1
- 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 +16 -16
- 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 +5 -5
- 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/CardOrganization.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +42 -39
- 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 +4 -4
- 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 +121 -112
- 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 +17 -16
- 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 +121 -61
- 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 +6 -6
- package/dist/prometheus-framework/src/modules/organizations/store/invites.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/store/invites.js +25 -24
- 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/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/spots/components/blocks/CardSpot.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/blocks/SpotMemberModify.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/blocks/SpotMemberModify.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.js +4 -4
- package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.js +66 -67
- package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.js +4 -4
- 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 +78 -74
- package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardDeposit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardDeposit.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.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/reports.server.js +0 -3
- package/dist/reports.server.mjs +0 -3
- package/dist/style.css +1 -1
- package/dist/wallet.server.js +5 -5
- package/dist/wallet.server.mjs +8 -8
- package/package.json +1 -1
- package/src/components/Completion/Completion.vue +29 -30
- package/src/modules/auth/components/pages/Invite.vue +4 -2
- package/src/modules/auth/controllers/auth.controller.js +31 -13
- package/src/modules/auth/middlewares/authJwt.js +80 -0
- package/src/modules/{middlewares/server → auth/middlewares}/index.js +1 -3
- package/src/modules/{middlewares/server → auth/middlewares}/verifyAccesses.js +1 -1
- package/src/modules/auth/routes/auth.routes.js +2 -2
- package/src/modules/auth/routes/twofa.routes.js +1 -1
- package/src/modules/auth/store/auth.js +9 -0
- package/src/modules/chats/routes/chats.routes.js +1 -1
- package/src/modules/community/routes/blog.routes.js +2 -2
- package/src/modules/events/routes/events.routes.js +2 -2
- package/src/modules/files/routes/files.routes.js +2 -2
- package/src/modules/gallery/components/pages/Gallery.vue +1 -1
- package/src/modules/gallery/routes/gallery.routes.js +4 -5
- package/src/modules/globals/services/globals.crud.js +2 -2
- package/src/modules/marketplace/store/marketplace.js +1 -1
- package/src/modules/orders/components/pages/OrderCreateBackoffice.vue +2 -2
- package/src/modules/orders/components/sections/FormAddCustomer.vue +2 -2
- package/src/modules/orders/controllers/orders.controller.js +1 -2
- package/src/modules/orders/routes/applications.routes.js +2 -2
- package/src/modules/orders/routes/orders.routes.js +2 -2
- package/src/modules/organizations/components/blocks/CardOrganization.vue +9 -7
- package/src/modules/organizations/components/pages/Members.vue +26 -15
- package/src/modules/organizations/components/sections/DetailsTab.vue +1 -1
- package/src/modules/organizations/components/sections/MembersAdd.vue +101 -43
- package/src/modules/organizations/controllers/invites.controller.js +18 -13
- package/src/modules/organizations/controllers/memberships.controller.js +16 -9
- package/src/modules/organizations/controllers/organizations.controller.js +3 -4
- package/src/modules/organizations/models/membership.model.js +2 -0
- package/src/modules/organizations/models/organization.model.js +4 -0
- package/src/modules/organizations/routes/invites.routes.js +2 -2
- package/src/modules/organizations/store/invites.js +2 -1
- package/src/modules/products/controllers/leftovers.controller.js +1 -1
- package/src/modules/products/middlewares/index.js +11 -0
- package/src/modules/products/routes/categories.routes.js +2 -2
- package/src/modules/reports/routes/reports.routes.js +2 -2
- package/src/modules/spots/components/layouts/Spots.vue +2 -2
- package/src/modules/spots/components/pages/Map.vue +79 -78
- package/src/modules/users/components/pages/ProfileEdit.vue +37 -22
- package/src/modules/wallet/controllers/routes/payments.routes.js +2 -2
- package/src/modules/wallet/controllers/routes/rewards.routes.js +2 -2
- package/src/modules/middlewares/server/authJwt.js +0 -68
- /package/src/modules/{middlewares/server → auth/middlewares}/authSecret.js +0 -0
- /package/src/modules/{middlewares/server → auth/middlewares}/verifyInvites.js +0 -0
- /package/src/modules/{middlewares/server → auth/middlewares}/verifySignUp.js +0 -0
- /package/src/modules/{middlewares/server → auth/middlewares}/verifyUser.js +0 -0
- /package/src/modules/globals/services/{globals.cashe.js → globals.cache.js} +0 -0
- /package/src/modules/{middlewares/server → products/middlewares}/verifyCategory.js +0 -0
package/dist/auth.server.js
CHANGED
@@ -5,7 +5,7 @@ const require$$1$1 = require("bcryptjs");
|
|
5
5
|
const require$$0$1 = require("mongoose");
|
6
6
|
const require$$1 = require("jwk-to-pem");
|
7
7
|
const mailing = require("./mailing-BX0q8DIs.js");
|
8
|
-
const index = require("./index-
|
8
|
+
const index = require("./index-DNI4aUP2.js");
|
9
9
|
const jwt$1 = require$$0;
|
10
10
|
const jwkToPem = require$$1;
|
11
11
|
async function verifyAppleIdToken$1(id_token) {
|
@@ -98,7 +98,7 @@ const controllerFactory$3 = (db) => {
|
|
98
98
|
const token = jwt.sign({
|
99
99
|
_id: user._id
|
100
100
|
}, process.env.SECRET_KEY, {
|
101
|
-
expiresIn:
|
101
|
+
expiresIn: 864e3
|
102
102
|
});
|
103
103
|
const authorities = user.roles.map((role) => `ROLE_${role.name.toUpperCase()}`);
|
104
104
|
res.status(200).send({
|
@@ -228,16 +228,13 @@ const controllerFactory$3 = (db) => {
|
|
228
228
|
const ownedOrgs = await Organization.find({ owner: uid });
|
229
229
|
const ownedOrgIds = ownedOrgs.map((org) => org._id.toString());
|
230
230
|
const accesses = {};
|
231
|
-
const processAccesses = (orgId, isOwner) => {
|
231
|
+
const processAccesses = (orgId, isOwner, deptAccesses) => {
|
232
232
|
if (!accesses[orgId]) {
|
233
|
-
accesses[orgId] = {
|
234
|
-
organization: orgId,
|
235
|
-
rights: {}
|
236
|
-
};
|
233
|
+
accesses[orgId] = { organization: orgId, rights: {} };
|
237
234
|
}
|
238
235
|
const rights = accesses[orgId].rights;
|
239
|
-
const defaultAccesses = new Department();
|
240
|
-
const accessData = isOwner ? defaultAccesses
|
236
|
+
const defaultAccesses = new Department().accesses;
|
237
|
+
const accessData = isOwner ? defaultAccesses : deptAccesses;
|
241
238
|
Object.keys(accessData).forEach((key) => {
|
242
239
|
if (!rights[key]) {
|
243
240
|
rights[key] = {};
|
@@ -248,12 +245,30 @@ const controllerFactory$3 = (db) => {
|
|
248
245
|
});
|
249
246
|
});
|
250
247
|
};
|
251
|
-
depts.
|
248
|
+
const orgDepts = depts.reduce((acc, dept) => {
|
252
249
|
const orgId = dept.organization.toString();
|
253
|
-
|
250
|
+
if (!acc[orgId]) {
|
251
|
+
acc[orgId] = [];
|
252
|
+
}
|
253
|
+
acc[orgId].push(dept);
|
254
|
+
return acc;
|
255
|
+
}, {});
|
256
|
+
Object.entries(orgDepts).forEach(([orgId, departments]) => {
|
257
|
+
const combinedAccesses = departments.reduce((acc, dept) => {
|
258
|
+
Object.entries(dept.accesses).forEach(([key, rights]) => {
|
259
|
+
if (!acc[key]) {
|
260
|
+
acc[key] = {};
|
261
|
+
}
|
262
|
+
Object.entries(rights).forEach(([right, value]) => {
|
263
|
+
acc[key][right] = acc[key][right] || value;
|
264
|
+
});
|
265
|
+
});
|
266
|
+
return acc;
|
267
|
+
}, {});
|
268
|
+
processAccesses(orgId, false, combinedAccesses);
|
254
269
|
});
|
255
270
|
ownedOrgIds.forEach((orgId) => {
|
256
|
-
processAccesses(orgId, true);
|
271
|
+
processAccesses(orgId, true, {});
|
257
272
|
});
|
258
273
|
const accessArray = Object.values(accesses);
|
259
274
|
res.status(200).json(accessArray);
|
@@ -301,7 +316,7 @@ const controllerFactory$2 = (db) => {
|
|
301
316
|
var twofa_controller = controllerFactory$2;
|
302
317
|
const controllerFactory$1 = auth_controller;
|
303
318
|
const controllerFactoryTwofa = twofa_controller;
|
304
|
-
const middlewareFactory$1 = index.
|
319
|
+
const middlewareFactory$1 = index.middlewares;
|
305
320
|
var auth_routes = function(app, db, origins) {
|
306
321
|
const controller = controllerFactory$1(db);
|
307
322
|
const controllerTwofa = controllerFactoryTwofa();
|
@@ -332,13 +347,13 @@ var auth_routes = function(app, db, origins) {
|
|
332
347
|
app.get(
|
333
348
|
"/api/auth/check-accesses",
|
334
349
|
[
|
335
|
-
authJwt.verifyToken
|
350
|
+
authJwt.verifyToken(true)
|
336
351
|
],
|
337
352
|
controller.checkAccesses
|
338
353
|
);
|
339
354
|
};
|
340
355
|
const controllerFactory = twofa_controller;
|
341
|
-
const middlewareFactory = index.
|
356
|
+
const middlewareFactory = index.middlewares;
|
342
357
|
var twofa_routes = function(app, db) {
|
343
358
|
const controller = controllerFactory();
|
344
359
|
const { verifySignUp, verifyUser } = middlewareFactory(db);
|
package/dist/auth.server.mjs
CHANGED
@@ -4,7 +4,7 @@ import require$$1$1 from "bcryptjs";
|
|
4
4
|
import require$$0$1 from "mongoose";
|
5
5
|
import require$$1 from "jwk-to-pem";
|
6
6
|
import { m as mailing } from "./mailing-Cdp8NXhP.mjs";
|
7
|
-
import {
|
7
|
+
import { m as middlewares } from "./index-Tcyehi73.mjs";
|
8
8
|
const jwt$1 = require$$0;
|
9
9
|
const jwkToPem = require$$1;
|
10
10
|
async function verifyAppleIdToken$1(id_token) {
|
@@ -97,7 +97,7 @@ const controllerFactory$3 = (db) => {
|
|
97
97
|
const token = jwt.sign({
|
98
98
|
_id: user._id
|
99
99
|
}, process.env.SECRET_KEY, {
|
100
|
-
expiresIn:
|
100
|
+
expiresIn: 864e3
|
101
101
|
});
|
102
102
|
const authorities = user.roles.map((role) => `ROLE_${role.name.toUpperCase()}`);
|
103
103
|
res.status(200).send({
|
@@ -227,16 +227,13 @@ const controllerFactory$3 = (db) => {
|
|
227
227
|
const ownedOrgs = await Organization.find({ owner: uid });
|
228
228
|
const ownedOrgIds = ownedOrgs.map((org) => org._id.toString());
|
229
229
|
const accesses = {};
|
230
|
-
const processAccesses = (orgId, isOwner) => {
|
230
|
+
const processAccesses = (orgId, isOwner, deptAccesses) => {
|
231
231
|
if (!accesses[orgId]) {
|
232
|
-
accesses[orgId] = {
|
233
|
-
organization: orgId,
|
234
|
-
rights: {}
|
235
|
-
};
|
232
|
+
accesses[orgId] = { organization: orgId, rights: {} };
|
236
233
|
}
|
237
234
|
const rights = accesses[orgId].rights;
|
238
|
-
const defaultAccesses = new Department();
|
239
|
-
const accessData = isOwner ? defaultAccesses
|
235
|
+
const defaultAccesses = new Department().accesses;
|
236
|
+
const accessData = isOwner ? defaultAccesses : deptAccesses;
|
240
237
|
Object.keys(accessData).forEach((key) => {
|
241
238
|
if (!rights[key]) {
|
242
239
|
rights[key] = {};
|
@@ -247,12 +244,30 @@ const controllerFactory$3 = (db) => {
|
|
247
244
|
});
|
248
245
|
});
|
249
246
|
};
|
250
|
-
depts.
|
247
|
+
const orgDepts = depts.reduce((acc, dept) => {
|
251
248
|
const orgId = dept.organization.toString();
|
252
|
-
|
249
|
+
if (!acc[orgId]) {
|
250
|
+
acc[orgId] = [];
|
251
|
+
}
|
252
|
+
acc[orgId].push(dept);
|
253
|
+
return acc;
|
254
|
+
}, {});
|
255
|
+
Object.entries(orgDepts).forEach(([orgId, departments]) => {
|
256
|
+
const combinedAccesses = departments.reduce((acc, dept) => {
|
257
|
+
Object.entries(dept.accesses).forEach(([key, rights]) => {
|
258
|
+
if (!acc[key]) {
|
259
|
+
acc[key] = {};
|
260
|
+
}
|
261
|
+
Object.entries(rights).forEach(([right, value]) => {
|
262
|
+
acc[key][right] = acc[key][right] || value;
|
263
|
+
});
|
264
|
+
});
|
265
|
+
return acc;
|
266
|
+
}, {});
|
267
|
+
processAccesses(orgId, false, combinedAccesses);
|
253
268
|
});
|
254
269
|
ownedOrgIds.forEach((orgId) => {
|
255
|
-
processAccesses(orgId, true);
|
270
|
+
processAccesses(orgId, true, {});
|
256
271
|
});
|
257
272
|
const accessArray = Object.values(accesses);
|
258
273
|
res.status(200).json(accessArray);
|
@@ -300,7 +315,7 @@ const controllerFactory$2 = (db) => {
|
|
300
315
|
var twofa_controller = controllerFactory$2;
|
301
316
|
const controllerFactory$1 = auth_controller;
|
302
317
|
const controllerFactoryTwofa = twofa_controller;
|
303
|
-
const middlewareFactory$1 =
|
318
|
+
const middlewareFactory$1 = middlewares;
|
304
319
|
var auth_routes = function(app, db, origins) {
|
305
320
|
const controller = controllerFactory$1(db);
|
306
321
|
const controllerTwofa = controllerFactoryTwofa();
|
@@ -331,13 +346,13 @@ var auth_routes = function(app, db, origins) {
|
|
331
346
|
app.get(
|
332
347
|
"/api/auth/check-accesses",
|
333
348
|
[
|
334
|
-
authJwt.verifyToken
|
349
|
+
authJwt.verifyToken(true)
|
335
350
|
],
|
336
351
|
controller.checkAccesses
|
337
352
|
);
|
338
353
|
};
|
339
354
|
const controllerFactory = twofa_controller;
|
340
|
-
const middlewareFactory =
|
355
|
+
const middlewareFactory = middlewares;
|
341
356
|
var twofa_routes = function(app, db) {
|
342
357
|
const controller = controllerFactory();
|
343
358
|
const { verifySignUp, verifyUser } = middlewareFactory(db);
|
package/dist/community.server.js
CHANGED
@@ -4,7 +4,7 @@ const require$$0 = require("mongoose");
|
|
4
4
|
const queryProcessor$3 = require("./queryProcessor-iewDZq_f.js");
|
5
5
|
require("util");
|
6
6
|
require("uuid");
|
7
|
-
const index = require("./index-
|
7
|
+
const index = require("./index-DNI4aUP2.js");
|
8
8
|
const common_schema = require("./common.schema-BFhpUXUt.js");
|
9
9
|
const engagement_schema = require("./engagement.schema-D-9md46B.js");
|
10
10
|
const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
|
@@ -651,11 +651,11 @@ const middlewareIndexFactory = (db) => {
|
|
651
651
|
};
|
652
652
|
var server = middlewareIndexFactory;
|
653
653
|
const controllerFactory$2 = blog_controller;
|
654
|
-
const
|
654
|
+
const middlewareFactoryAuth = index.middlewares;
|
655
655
|
const middlewareFactoryCommunity = server;
|
656
656
|
var blog_routes = function(app, db, origins) {
|
657
657
|
const controller = controllerFactory$2(db);
|
658
|
-
|
658
|
+
middlewareFactoryAuth(db);
|
659
659
|
const { verifyBlogpost: verifyBlogpost2 } = middlewareFactoryCommunity(db);
|
660
660
|
app.get(
|
661
661
|
"/api/blog/read",
|
@@ -3,7 +3,7 @@ import require$$0 from "mongoose";
|
|
3
3
|
import { q as queryProcessor$3 } from "./queryProcessor-DQSFR9YA.mjs";
|
4
4
|
import "util";
|
5
5
|
import "uuid";
|
6
|
-
import {
|
6
|
+
import { m as middlewares } from "./index-Tcyehi73.mjs";
|
7
7
|
import { c as common_schema } from "./common.schema-ChBVARrs.mjs";
|
8
8
|
import { e as engagement_schema } from "./engagement.schema-CCdSLKd4.mjs";
|
9
9
|
import { o as ownership_schema } from "./ownership.schema-oyx6eNkZ.mjs";
|
@@ -650,11 +650,11 @@ const middlewareIndexFactory = (db) => {
|
|
650
650
|
};
|
651
651
|
var server = middlewareIndexFactory;
|
652
652
|
const controllerFactory$2 = blog_controller;
|
653
|
-
const
|
653
|
+
const middlewareFactoryAuth = middlewares;
|
654
654
|
const middlewareFactoryCommunity = server;
|
655
655
|
var blog_routes = function(app, db, origins) {
|
656
656
|
const controller = controllerFactory$2(db);
|
657
|
-
|
657
|
+
middlewareFactoryAuth(db);
|
658
658
|
const { verifyBlogpost: verifyBlogpost2 } = middlewareFactoryCommunity(db);
|
659
659
|
app.get(
|
660
660
|
"/api/blog/read",
|
package/dist/events.server.js
CHANGED
@@ -5,7 +5,7 @@ const require$$0 = require("mongoose");
|
|
5
5
|
const queryProcessor$2 = require("./queryProcessor-iewDZq_f.js");
|
6
6
|
const metadata_schema = require("./metadata.schema-6slGhpQS.js");
|
7
7
|
const require$$1 = require("stripe");
|
8
|
-
const index = require("./index-
|
8
|
+
const index = require("./index-DNI4aUP2.js");
|
9
9
|
const tickets_controller = require("./tickets.controller-WaQ4qMpv.js");
|
10
10
|
const common_schema = require("./common.schema-BFhpUXUt.js");
|
11
11
|
const engagement_schema = require("./engagement.schema-D-9md46B.js");
|
@@ -641,11 +641,11 @@ const middlewareIndexFactory = (db) => {
|
|
641
641
|
};
|
642
642
|
var server = middlewareIndexFactory;
|
643
643
|
const controllerFactory$1 = events_controller;
|
644
|
-
const
|
644
|
+
const middlewareFactoryAuth = index.middlewares;
|
645
645
|
const middlewareFactoryEvents = server;
|
646
646
|
var events_routes = function(app, db, origins) {
|
647
647
|
const controller = controllerFactory$1(db);
|
648
|
-
|
648
|
+
middlewareFactoryAuth(db);
|
649
649
|
const { verifyEvent: verifyEvent2 } = middlewareFactoryEvents(db);
|
650
650
|
app.get(
|
651
651
|
"/api/events/read",
|
package/dist/events.server.mjs
CHANGED
@@ -3,7 +3,7 @@ import require$$0 from "mongoose";
|
|
3
3
|
import { q as queryProcessor$2 } from "./queryProcessor-DQSFR9YA.mjs";
|
4
4
|
import { s as seoFriendlyUrl, m as metadata_schema } from "./metadata.schema-CK5e2O3f.mjs";
|
5
5
|
import require$$1 from "stripe";
|
6
|
-
import {
|
6
|
+
import { m as middlewares } from "./index-Tcyehi73.mjs";
|
7
7
|
import { t as tickets_controller } from "./tickets.controller-ByZ33N6_.mjs";
|
8
8
|
import { c as common_schema } from "./common.schema-ChBVARrs.mjs";
|
9
9
|
import { e as engagement_schema } from "./engagement.schema-CCdSLKd4.mjs";
|
@@ -639,11 +639,11 @@ const middlewareIndexFactory = (db) => {
|
|
639
639
|
};
|
640
640
|
var server = middlewareIndexFactory;
|
641
641
|
const controllerFactory$1 = events_controller;
|
642
|
-
const
|
642
|
+
const middlewareFactoryAuth = middlewares;
|
643
643
|
const middlewareFactoryEvents = server;
|
644
644
|
var events_routes = function(app, db, origins) {
|
645
645
|
const controller = controllerFactory$1(db);
|
646
|
-
|
646
|
+
middlewareFactoryAuth(db);
|
647
647
|
const { verifyEvent: verifyEvent2 } = middlewareFactoryEvents(db);
|
648
648
|
app.get(
|
649
649
|
"/api/events/read",
|
package/dist/files.server.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
|
3
3
|
const require$$0 = require("path");
|
4
|
-
const index = require("./index-
|
4
|
+
const index = require("./index-DNI4aUP2.js");
|
5
5
|
const require$$0$1 = require("sharp");
|
6
6
|
const require$$1 = require("fs");
|
7
7
|
const require$$2 = require("fs/promises");
|
@@ -250,11 +250,11 @@ const middlewareIndexFactory = (db, publicPath) => {
|
|
250
250
|
};
|
251
251
|
var server = middlewareIndexFactory;
|
252
252
|
const controllerFactory = files_controller;
|
253
|
-
const
|
253
|
+
const middlewareFactoryAuth = index.middlewares;
|
254
254
|
const middlewareFactoryFiles = server;
|
255
255
|
var files_routes = function(app, db, origins, publicPath) {
|
256
256
|
const controller = controllerFactory();
|
257
|
-
|
257
|
+
middlewareFactoryAuth(db);
|
258
258
|
const { middlewareBusboy: middlewareBusboy2 } = middlewareFactoryFiles(db, publicPath);
|
259
259
|
app.post(
|
260
260
|
"/api/upload/image",
|
package/dist/files.server.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
|
2
2
|
import require$$0 from "path";
|
3
|
-
import {
|
3
|
+
import { m as middlewares } from "./index-Tcyehi73.mjs";
|
4
4
|
import require$$0$1 from "sharp";
|
5
5
|
import require$$1 from "fs";
|
6
6
|
import require$$2 from "fs/promises";
|
@@ -249,11 +249,11 @@ const middlewareIndexFactory = (db, publicPath) => {
|
|
249
249
|
};
|
250
250
|
var server = middlewareIndexFactory;
|
251
251
|
const controllerFactory = files_controller;
|
252
|
-
const
|
252
|
+
const middlewareFactoryAuth = middlewares;
|
253
253
|
const middlewareFactoryFiles = server;
|
254
254
|
var files_routes = function(app, db, origins, publicPath) {
|
255
255
|
const controller = controllerFactory();
|
256
|
-
|
256
|
+
middlewareFactoryAuth(db);
|
257
257
|
const { middlewareBusboy: middlewareBusboy2 } = middlewareFactoryFiles(db, publicPath);
|
258
258
|
app.post(
|
259
259
|
"/api/upload/image",
|
package/dist/gallery.server.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
|
3
3
|
const require$$0 = require("path");
|
4
4
|
const queryProcessor = require("./queryProcessor-iewDZq_f.js");
|
5
|
-
const index = require("./index-
|
5
|
+
const index = require("./index-DNI4aUP2.js");
|
6
6
|
const common_schema = require("./common.schema-BFhpUXUt.js");
|
7
7
|
const engagement_schema = require("./engagement.schema-D-9md46B.js");
|
8
8
|
const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
|
@@ -167,16 +167,16 @@ const middlewareFactory = (db) => {
|
|
167
167
|
};
|
168
168
|
var verifyAccesses = middlewareFactory;
|
169
169
|
const controllerFactory = gallery_controller;
|
170
|
-
const
|
170
|
+
const middlewareFactoryAuth = index.middlewares;
|
171
171
|
const middlewareFactoryAccesses = verifyAccesses;
|
172
172
|
var gallery_routes = function(app, db, origins) {
|
173
173
|
const controller = controllerFactory(db);
|
174
|
-
const { authJwt } =
|
174
|
+
const { authJwt } = middlewareFactoryAuth(db);
|
175
175
|
const { verifyRead } = middlewareFactoryAccesses(db);
|
176
176
|
app.get(
|
177
177
|
"/api/gallery/read",
|
178
178
|
[
|
179
|
-
authJwt.verifyToken,
|
179
|
+
authJwt.verifyToken(true),
|
180
180
|
verifyRead("gallery")
|
181
181
|
],
|
182
182
|
controller.read
|
package/dist/gallery.server.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
|
2
2
|
import require$$0 from "path";
|
3
3
|
import { q as queryProcessor } from "./queryProcessor-DQSFR9YA.mjs";
|
4
|
-
import {
|
4
|
+
import { m as middlewares } from "./index-Tcyehi73.mjs";
|
5
5
|
import { c as common_schema } from "./common.schema-ChBVARrs.mjs";
|
6
6
|
import { e as engagement_schema } from "./engagement.schema-CCdSLKd4.mjs";
|
7
7
|
import { o as ownership_schema } from "./ownership.schema-oyx6eNkZ.mjs";
|
@@ -166,16 +166,16 @@ const middlewareFactory = (db) => {
|
|
166
166
|
};
|
167
167
|
var verifyAccesses = middlewareFactory;
|
168
168
|
const controllerFactory = gallery_controller;
|
169
|
-
const
|
169
|
+
const middlewareFactoryAuth = middlewares;
|
170
170
|
const middlewareFactoryAccesses = verifyAccesses;
|
171
171
|
var gallery_routes = function(app, db, origins) {
|
172
172
|
const controller = controllerFactory(db);
|
173
|
-
const { authJwt } =
|
173
|
+
const { authJwt } = middlewareFactoryAuth(db);
|
174
174
|
const { verifyRead } = middlewareFactoryAccesses(db);
|
175
175
|
app.get(
|
176
176
|
"/api/gallery/read",
|
177
177
|
[
|
178
|
-
authJwt.verifyToken,
|
178
|
+
authJwt.verifyToken(true),
|
179
179
|
verifyRead("gallery")
|
180
180
|
],
|
181
181
|
controller.read
|
@@ -0,0 +1,259 @@
|
|
1
|
+
"use strict";
|
2
|
+
const require$$0 = require("jsonwebtoken");
|
3
|
+
const require$$0$1 = require("crypto");
|
4
|
+
const require$$0$2 = require("mongodb");
|
5
|
+
var authJwt;
|
6
|
+
var hasRequiredAuthJwt;
|
7
|
+
function requireAuthJwt() {
|
8
|
+
if (hasRequiredAuthJwt) return authJwt;
|
9
|
+
hasRequiredAuthJwt = 1;
|
10
|
+
const jwt = require$$0;
|
11
|
+
const middlewareFactory = (db) => {
|
12
|
+
const User = db.user;
|
13
|
+
const Role = db.role;
|
14
|
+
const verifyToken = (continueOnFail = false) => {
|
15
|
+
return async (req, res, next) => {
|
16
|
+
try {
|
17
|
+
if (!req.cookies.user) {
|
18
|
+
req.userId = null;
|
19
|
+
if (continueOnFail) {
|
20
|
+
return next();
|
21
|
+
} else {
|
22
|
+
return res.status(401).send({ message: "Unauthorized: No user cookie" });
|
23
|
+
}
|
24
|
+
}
|
25
|
+
let user = JSON.parse(req.cookies.user);
|
26
|
+
let token = req.headers["x-access-token"] || user.accessToken;
|
27
|
+
if (!token) {
|
28
|
+
req.userId = null;
|
29
|
+
if (continueOnFail) {
|
30
|
+
return next();
|
31
|
+
} else {
|
32
|
+
return res.status(401).send({ message: "Unauthorized: No token provided" });
|
33
|
+
}
|
34
|
+
}
|
35
|
+
const decoded = jwt.verify(token, process.env.SECRET_KEY);
|
36
|
+
req.userId = decoded._id;
|
37
|
+
next();
|
38
|
+
} catch (err) {
|
39
|
+
console.log(err);
|
40
|
+
req.userId = null;
|
41
|
+
if (continueOnFail) {
|
42
|
+
next();
|
43
|
+
} else {
|
44
|
+
res.status(401).send({ message: "Unauthorized: Invalid token" });
|
45
|
+
}
|
46
|
+
}
|
47
|
+
};
|
48
|
+
};
|
49
|
+
const checkRole = (roleToCheck) => async (req, res, next) => {
|
50
|
+
try {
|
51
|
+
const user = await User.findById(req.userId).exec();
|
52
|
+
if (!user) {
|
53
|
+
return res.status(404).send({ message: "User Not found." });
|
54
|
+
}
|
55
|
+
const roles = await Role.find({ _id: { $in: user.roles } }).exec();
|
56
|
+
for (let role of roles) {
|
57
|
+
if (role.name === roleToCheck) {
|
58
|
+
next();
|
59
|
+
return;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
res.status(403).send({ message: `Require ${roleToCheck} Role!` });
|
63
|
+
} catch (err) {
|
64
|
+
res.status(500).send({ message: err.message });
|
65
|
+
}
|
66
|
+
};
|
67
|
+
const isAdmin = checkRole("admin");
|
68
|
+
const isModerator = checkRole("moderator");
|
69
|
+
return {
|
70
|
+
verifyToken,
|
71
|
+
isAdmin,
|
72
|
+
isModerator
|
73
|
+
};
|
74
|
+
};
|
75
|
+
authJwt = middlewareFactory;
|
76
|
+
return authJwt;
|
77
|
+
}
|
78
|
+
var authSecret;
|
79
|
+
var hasRequiredAuthSecret;
|
80
|
+
function requireAuthSecret() {
|
81
|
+
if (hasRequiredAuthSecret) return authSecret;
|
82
|
+
hasRequiredAuthSecret = 1;
|
83
|
+
const crypto = require$$0$1;
|
84
|
+
const middlewareFactory = () => {
|
85
|
+
const verifySecret = (method, endpoint, secret) => async (req, res, next) => {
|
86
|
+
const requestSignature = req.headers.signature;
|
87
|
+
const signature = crypto.createHmac("sha256", secret).update(method + endpoint).digest("hex");
|
88
|
+
if (signature === requestSignature) {
|
89
|
+
return next();
|
90
|
+
}
|
91
|
+
res.status(403).send("Forbidden");
|
92
|
+
};
|
93
|
+
return { verifySecret };
|
94
|
+
};
|
95
|
+
authSecret = middlewareFactory;
|
96
|
+
return authSecret;
|
97
|
+
}
|
98
|
+
var verifySignUp;
|
99
|
+
var hasRequiredVerifySignUp;
|
100
|
+
function requireVerifySignUp() {
|
101
|
+
if (hasRequiredVerifySignUp) return verifySignUp;
|
102
|
+
hasRequiredVerifySignUp = 1;
|
103
|
+
const middlewareFactory = (db) => {
|
104
|
+
const User = db.user;
|
105
|
+
db.role;
|
106
|
+
const checkDuplicateUsernameOrEmail = async (req, res, next) => {
|
107
|
+
const { type, email, phone } = req.body;
|
108
|
+
console.log(req.body);
|
109
|
+
let query;
|
110
|
+
if (type === "phone" && phone) {
|
111
|
+
query = { phone };
|
112
|
+
}
|
113
|
+
if (type === "email" && email) {
|
114
|
+
query = { email };
|
115
|
+
}
|
116
|
+
try {
|
117
|
+
const user = await User.findOne(query).exec();
|
118
|
+
if (user) {
|
119
|
+
console.log(`USER_ALREADY_REGISTERED`);
|
120
|
+
res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
|
121
|
+
return;
|
122
|
+
}
|
123
|
+
next();
|
124
|
+
} catch (err) {
|
125
|
+
console.log(err);
|
126
|
+
res.status(500).send({ message: err.message });
|
127
|
+
}
|
128
|
+
};
|
129
|
+
const checkRolesExisted = (req, res, next) => {
|
130
|
+
if (req.body.roles) {
|
131
|
+
for (let i = 0; i < req.body.roles.length; i++) {
|
132
|
+
if (!ROLES.includes(req.body.roles[i])) {
|
133
|
+
console.log(`Failed! Role ${req.body.roles[i]} does not exist!`);
|
134
|
+
res.status(400).send({
|
135
|
+
message: `Failed! Role ${req.body.roles[i]} does not exist!`
|
136
|
+
});
|
137
|
+
return;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
next();
|
142
|
+
};
|
143
|
+
return {
|
144
|
+
checkDuplicateUsernameOrEmail,
|
145
|
+
checkRolesExisted
|
146
|
+
};
|
147
|
+
};
|
148
|
+
verifySignUp = middlewareFactory;
|
149
|
+
return verifySignUp;
|
150
|
+
}
|
151
|
+
var verifyUser;
|
152
|
+
var hasRequiredVerifyUser;
|
153
|
+
function requireVerifyUser() {
|
154
|
+
if (hasRequiredVerifyUser) return verifyUser;
|
155
|
+
hasRequiredVerifyUser = 1;
|
156
|
+
const middlewareFactory = (db) => {
|
157
|
+
const User = db.user;
|
158
|
+
db.role;
|
159
|
+
const checkUserExist = async (req, res, next) => {
|
160
|
+
const { type, email, phone } = req.body;
|
161
|
+
let query;
|
162
|
+
if (type === "phone" && phone) {
|
163
|
+
query = { phone };
|
164
|
+
}
|
165
|
+
if (type === "email" && email) {
|
166
|
+
query = { email };
|
167
|
+
}
|
168
|
+
try {
|
169
|
+
const user = await User.findOne(query).exec();
|
170
|
+
if (!user) {
|
171
|
+
console.log(query);
|
172
|
+
res.status(400).send({ errorCode: "USER_NOT_REGISTERED_YET" });
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
next();
|
176
|
+
} catch (err) {
|
177
|
+
res.status(500).send({ message: err.message });
|
178
|
+
}
|
179
|
+
};
|
180
|
+
return {
|
181
|
+
checkUserExist
|
182
|
+
};
|
183
|
+
};
|
184
|
+
verifyUser = middlewareFactory;
|
185
|
+
return verifyUser;
|
186
|
+
}
|
187
|
+
var verifyInvites;
|
188
|
+
var hasRequiredVerifyInvites;
|
189
|
+
function requireVerifyInvites() {
|
190
|
+
if (hasRequiredVerifyInvites) return verifyInvites;
|
191
|
+
hasRequiredVerifyInvites = 1;
|
192
|
+
const { ObjectId } = require$$0$2;
|
193
|
+
const middlewareFactory = (db) => {
|
194
|
+
const User = db.user;
|
195
|
+
const Invite = db.invite;
|
196
|
+
const Membership = db.membership;
|
197
|
+
const checkInviteExist = async (req, res, next) => {
|
198
|
+
for (let invite of req.body.invites) {
|
199
|
+
let query;
|
200
|
+
if (invite.contact.includes("@")) {
|
201
|
+
query = { invitedEmail: invite.contact };
|
202
|
+
} else {
|
203
|
+
query = { invitedPhone: invite.contact };
|
204
|
+
}
|
205
|
+
query["owner.target"] = req.body.owner.target;
|
206
|
+
const userInvite = await Invite.findOne(query).exec();
|
207
|
+
if (userInvite) {
|
208
|
+
console.log(userInvite);
|
209
|
+
res.status(400).send({ message: "Инвайт c таким email или телефоном уже создан!" });
|
210
|
+
return;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
next();
|
214
|
+
};
|
215
|
+
const checkUsersExist = async (req, res, next) => {
|
216
|
+
for (let invite of req.body.invites) {
|
217
|
+
let query;
|
218
|
+
if (invite.contact.includes("@")) {
|
219
|
+
query = { email: invite.contact };
|
220
|
+
} else {
|
221
|
+
query = { phone: invite.contact };
|
222
|
+
}
|
223
|
+
const user = await User.findOne(query).exec();
|
224
|
+
console.log(req.params);
|
225
|
+
if (user) {
|
226
|
+
const membership = await Membership.findOne({ user: new ObjectId(user._id), "owner.target": req.body.owner.target }).exec();
|
227
|
+
if (membership) {
|
228
|
+
console.log(membership);
|
229
|
+
res.status(400).send({ message: "Пользователь с таким email или телефоном уже добавлен в организацию!" });
|
230
|
+
return;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|
234
|
+
next();
|
235
|
+
};
|
236
|
+
return {
|
237
|
+
checkInviteExist,
|
238
|
+
checkUsersExist
|
239
|
+
};
|
240
|
+
};
|
241
|
+
verifyInvites = middlewareFactory;
|
242
|
+
return verifyInvites;
|
243
|
+
}
|
244
|
+
const middlewareIndexFactory = (db) => {
|
245
|
+
const authJwt2 = requireAuthJwt()(db);
|
246
|
+
const authSecret2 = requireAuthSecret()();
|
247
|
+
const verifySignUp2 = requireVerifySignUp()(db);
|
248
|
+
const verifyUser2 = requireVerifyUser()(db);
|
249
|
+
const verifyInvites2 = requireVerifyInvites()(db);
|
250
|
+
return {
|
251
|
+
authJwt: authJwt2,
|
252
|
+
authSecret: authSecret2,
|
253
|
+
verifySignUp: verifySignUp2,
|
254
|
+
verifyUser: verifyUser2,
|
255
|
+
verifyInvites: verifyInvites2
|
256
|
+
};
|
257
|
+
};
|
258
|
+
var middlewares = middlewareIndexFactory;
|
259
|
+
exports.middlewares = middlewares;
|