@ozdao/prometheus-framework 0.2.144 → 0.2.146
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth.server.js +1 -1
- package/dist/auth.server.mjs +1 -1
- package/dist/community.server.js +1 -1
- package/dist/community.server.mjs +1 -1
- package/dist/events.server.js +1 -1
- package/dist/events.server.mjs +1 -1
- package/dist/files.server.js +1 -1
- package/dist/files.server.mjs +1 -1
- package/dist/gallery.server.js +1 -1
- package/dist/gallery.server.mjs +1 -1
- package/dist/index-DahVPg_G.mjs +255 -0
- package/dist/index-oS9yx2Kv.js +254 -0
- package/dist/main-BFKp44Ze.mjs +14509 -0
- package/dist/main-By5Tbyui.js +92 -0
- package/dist/main-CEoQQpJV.js +92 -0
- package/dist/main-D_RRsfEH.mjs +14509 -0
- package/dist/orders.server.js +1 -1
- package/dist/orders.server.mjs +1 -1
- package/dist/organizations.server.js +1 -1
- package/dist/organizations.server.mjs +1 -1
- 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 +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 +50 -50
- 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 +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 +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/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/CardOrganization.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +1 -1
- 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 +1 -1
- 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 +2 -2
- 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 +6 -6
- 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 +2 -2
- 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 +1 -1
- 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 +2 -2
- 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/prometheus-framework.cjs.js +1 -1
- package/dist/prometheus-framework.es.js +1 -1
- package/dist/wallet.server.js +1 -1
- package/dist/wallet.server.mjs +1 -1
- package/dist/web-BmdKi_fZ.js +1 -0
- package/dist/web-Cw0ijzjY.js +1 -0
- package/dist/web-CwTWV4ca.mjs +54 -0
- package/dist/web-nqFW_Sd1.mjs +54 -0
- package/package.json +1 -1
- package/src/modules/auth/middlewares/authJwt.js +5 -11
- package/src/modules/auth/store/auth.js +6 -2
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-oS9yx2Kv.js");
|
9
9
|
const jwt$1 = require$$0;
|
10
10
|
const jwkToPem = require$$1;
|
11
11
|
async function verifyAppleIdToken$1(id_token) {
|
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 { m as middlewares } from "./index-
|
7
|
+
import { m as middlewares } from "./index-DahVPg_G.mjs";
|
8
8
|
const jwt$1 = require$$0;
|
9
9
|
const jwkToPem = require$$1;
|
10
10
|
async function verifyAppleIdToken$1(id_token) {
|
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-oS9yx2Kv.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");
|
@@ -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 { m as middlewares } from "./index-
|
6
|
+
import { m as middlewares } from "./index-DahVPg_G.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";
|
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-oS9yx2Kv.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");
|
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 { m as middlewares } from "./index-
|
6
|
+
import { m as middlewares } from "./index-DahVPg_G.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";
|
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-oS9yx2Kv.js");
|
5
5
|
const require$$0$1 = require("sharp");
|
6
6
|
const require$$1 = require("fs");
|
7
7
|
const require$$2 = require("fs/promises");
|
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 { m as middlewares } from "./index-
|
3
|
+
import { m as middlewares } from "./index-DahVPg_G.mjs";
|
4
4
|
import require$$0$1 from "sharp";
|
5
5
|
import require$$1 from "fs";
|
6
6
|
import require$$2 from "fs/promises";
|
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-oS9yx2Kv.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");
|
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 { m as middlewares } from "./index-
|
4
|
+
import { m as middlewares } from "./index-DahVPg_G.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";
|
@@ -0,0 +1,255 @@
|
|
1
|
+
import require$$0 from "jsonwebtoken";
|
2
|
+
import require$$0$1 from "crypto";
|
3
|
+
import require$$0$2 from "mongodb";
|
4
|
+
var authJwt;
|
5
|
+
var hasRequiredAuthJwt;
|
6
|
+
function requireAuthJwt() {
|
7
|
+
if (hasRequiredAuthJwt) return authJwt;
|
8
|
+
hasRequiredAuthJwt = 1;
|
9
|
+
const jwt = require$$0;
|
10
|
+
const middlewareFactory = (db) => {
|
11
|
+
const User = db.user;
|
12
|
+
const Role = db.role;
|
13
|
+
const verifyToken = (continueOnFail = false) => {
|
14
|
+
return async (req, res, next) => {
|
15
|
+
try {
|
16
|
+
let token = req.headers["x-access-token"];
|
17
|
+
if (!token && req.cookies.user) {
|
18
|
+
let user = JSON.parse(req.cookies.user);
|
19
|
+
token = user.accessToken;
|
20
|
+
}
|
21
|
+
if (!token) {
|
22
|
+
req.userId = null;
|
23
|
+
if (continueOnFail) {
|
24
|
+
return next();
|
25
|
+
} else {
|
26
|
+
return res.status(401).send({ message: "Unauthorized: No token provided" });
|
27
|
+
}
|
28
|
+
}
|
29
|
+
const decoded = jwt.verify(token, process.env.SECRET_KEY);
|
30
|
+
req.userId = decoded._id;
|
31
|
+
next();
|
32
|
+
} catch (err) {
|
33
|
+
console.log(err);
|
34
|
+
req.userId = null;
|
35
|
+
if (continueOnFail) {
|
36
|
+
next();
|
37
|
+
} else {
|
38
|
+
res.status(401).send({ message: "Unauthorized: Invalid token" });
|
39
|
+
}
|
40
|
+
}
|
41
|
+
};
|
42
|
+
};
|
43
|
+
const checkRole = (roleToCheck) => async (req, res, next) => {
|
44
|
+
try {
|
45
|
+
const user = await User.findById(req.userId).exec();
|
46
|
+
if (!user) {
|
47
|
+
return res.status(404).send({ message: "User Not found." });
|
48
|
+
}
|
49
|
+
const roles = await Role.find({ _id: { $in: user.roles } }).exec();
|
50
|
+
for (let role of roles) {
|
51
|
+
if (role.name === roleToCheck) {
|
52
|
+
next();
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
res.status(403).send({ message: `Require ${roleToCheck} Role!` });
|
57
|
+
} catch (err) {
|
58
|
+
res.status(500).send({ message: err.message });
|
59
|
+
}
|
60
|
+
};
|
61
|
+
const isAdmin = checkRole("admin");
|
62
|
+
const isModerator = checkRole("moderator");
|
63
|
+
return {
|
64
|
+
verifyToken,
|
65
|
+
isAdmin,
|
66
|
+
isModerator
|
67
|
+
};
|
68
|
+
};
|
69
|
+
authJwt = middlewareFactory;
|
70
|
+
return authJwt;
|
71
|
+
}
|
72
|
+
var authSecret;
|
73
|
+
var hasRequiredAuthSecret;
|
74
|
+
function requireAuthSecret() {
|
75
|
+
if (hasRequiredAuthSecret) return authSecret;
|
76
|
+
hasRequiredAuthSecret = 1;
|
77
|
+
const crypto = require$$0$1;
|
78
|
+
const middlewareFactory = () => {
|
79
|
+
const verifySecret = (method, endpoint, secret) => async (req, res, next) => {
|
80
|
+
const requestSignature = req.headers.signature;
|
81
|
+
const signature = crypto.createHmac("sha256", secret).update(method + endpoint).digest("hex");
|
82
|
+
if (signature === requestSignature) {
|
83
|
+
return next();
|
84
|
+
}
|
85
|
+
res.status(403).send("Forbidden");
|
86
|
+
};
|
87
|
+
return { verifySecret };
|
88
|
+
};
|
89
|
+
authSecret = middlewareFactory;
|
90
|
+
return authSecret;
|
91
|
+
}
|
92
|
+
var verifySignUp;
|
93
|
+
var hasRequiredVerifySignUp;
|
94
|
+
function requireVerifySignUp() {
|
95
|
+
if (hasRequiredVerifySignUp) return verifySignUp;
|
96
|
+
hasRequiredVerifySignUp = 1;
|
97
|
+
const middlewareFactory = (db) => {
|
98
|
+
const User = db.user;
|
99
|
+
db.role;
|
100
|
+
const checkDuplicateUsernameOrEmail = async (req, res, next) => {
|
101
|
+
const { type, email, phone } = req.body;
|
102
|
+
console.log(req.body);
|
103
|
+
let query;
|
104
|
+
if (type === "phone" && phone) {
|
105
|
+
query = { phone };
|
106
|
+
}
|
107
|
+
if (type === "email" && email) {
|
108
|
+
query = { email };
|
109
|
+
}
|
110
|
+
try {
|
111
|
+
const user = await User.findOne(query).exec();
|
112
|
+
if (user) {
|
113
|
+
console.log(`USER_ALREADY_REGISTERED`);
|
114
|
+
res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
next();
|
118
|
+
} catch (err) {
|
119
|
+
console.log(err);
|
120
|
+
res.status(500).send({ message: err.message });
|
121
|
+
}
|
122
|
+
};
|
123
|
+
const checkRolesExisted = (req, res, next) => {
|
124
|
+
if (req.body.roles) {
|
125
|
+
for (let i = 0; i < req.body.roles.length; i++) {
|
126
|
+
if (!ROLES.includes(req.body.roles[i])) {
|
127
|
+
console.log(`Failed! Role ${req.body.roles[i]} does not exist!`);
|
128
|
+
res.status(400).send({
|
129
|
+
message: `Failed! Role ${req.body.roles[i]} does not exist!`
|
130
|
+
});
|
131
|
+
return;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
next();
|
136
|
+
};
|
137
|
+
return {
|
138
|
+
checkDuplicateUsernameOrEmail,
|
139
|
+
checkRolesExisted
|
140
|
+
};
|
141
|
+
};
|
142
|
+
verifySignUp = middlewareFactory;
|
143
|
+
return verifySignUp;
|
144
|
+
}
|
145
|
+
var verifyUser;
|
146
|
+
var hasRequiredVerifyUser;
|
147
|
+
function requireVerifyUser() {
|
148
|
+
if (hasRequiredVerifyUser) return verifyUser;
|
149
|
+
hasRequiredVerifyUser = 1;
|
150
|
+
const middlewareFactory = (db) => {
|
151
|
+
const User = db.user;
|
152
|
+
db.role;
|
153
|
+
const checkUserExist = async (req, res, next) => {
|
154
|
+
const { type, email, phone } = req.body;
|
155
|
+
let query;
|
156
|
+
if (type === "phone" && phone) {
|
157
|
+
query = { phone };
|
158
|
+
}
|
159
|
+
if (type === "email" && email) {
|
160
|
+
query = { email };
|
161
|
+
}
|
162
|
+
try {
|
163
|
+
const user = await User.findOne(query).exec();
|
164
|
+
if (!user) {
|
165
|
+
console.log(query);
|
166
|
+
res.status(400).send({ errorCode: "USER_NOT_REGISTERED_YET" });
|
167
|
+
return;
|
168
|
+
}
|
169
|
+
next();
|
170
|
+
} catch (err) {
|
171
|
+
res.status(500).send({ message: err.message });
|
172
|
+
}
|
173
|
+
};
|
174
|
+
return {
|
175
|
+
checkUserExist
|
176
|
+
};
|
177
|
+
};
|
178
|
+
verifyUser = middlewareFactory;
|
179
|
+
return verifyUser;
|
180
|
+
}
|
181
|
+
var verifyInvites;
|
182
|
+
var hasRequiredVerifyInvites;
|
183
|
+
function requireVerifyInvites() {
|
184
|
+
if (hasRequiredVerifyInvites) return verifyInvites;
|
185
|
+
hasRequiredVerifyInvites = 1;
|
186
|
+
const { ObjectId } = require$$0$2;
|
187
|
+
const middlewareFactory = (db) => {
|
188
|
+
const User = db.user;
|
189
|
+
const Invite = db.invite;
|
190
|
+
const Membership = db.membership;
|
191
|
+
const checkInviteExist = async (req, res, next) => {
|
192
|
+
for (let invite of req.body.invites) {
|
193
|
+
let query;
|
194
|
+
if (invite.contact.includes("@")) {
|
195
|
+
query = { invitedEmail: invite.contact };
|
196
|
+
} else {
|
197
|
+
query = { invitedPhone: invite.contact };
|
198
|
+
}
|
199
|
+
query["owner.target"] = req.body.owner.target;
|
200
|
+
const userInvite = await Invite.findOne(query).exec();
|
201
|
+
if (userInvite) {
|
202
|
+
console.log(userInvite);
|
203
|
+
res.status(400).send({ message: "Инвайт c таким email или телефоном уже создан!" });
|
204
|
+
return;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
next();
|
208
|
+
};
|
209
|
+
const checkUsersExist = async (req, res, next) => {
|
210
|
+
for (let invite of req.body.invites) {
|
211
|
+
let query;
|
212
|
+
if (invite.contact.includes("@")) {
|
213
|
+
query = { email: invite.contact };
|
214
|
+
} else {
|
215
|
+
query = { phone: invite.contact };
|
216
|
+
}
|
217
|
+
const user = await User.findOne(query).exec();
|
218
|
+
console.log(req.params);
|
219
|
+
if (user) {
|
220
|
+
const membership = await Membership.findOne({ user: new ObjectId(user._id), "owner.target": req.body.owner.target }).exec();
|
221
|
+
if (membership) {
|
222
|
+
console.log(membership);
|
223
|
+
res.status(400).send({ message: "Пользователь с таким email или телефоном уже добавлен в организацию!" });
|
224
|
+
return;
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}
|
228
|
+
next();
|
229
|
+
};
|
230
|
+
return {
|
231
|
+
checkInviteExist,
|
232
|
+
checkUsersExist
|
233
|
+
};
|
234
|
+
};
|
235
|
+
verifyInvites = middlewareFactory;
|
236
|
+
return verifyInvites;
|
237
|
+
}
|
238
|
+
const middlewareIndexFactory = (db) => {
|
239
|
+
const authJwt2 = requireAuthJwt()(db);
|
240
|
+
const authSecret2 = requireAuthSecret()();
|
241
|
+
const verifySignUp2 = requireVerifySignUp()(db);
|
242
|
+
const verifyUser2 = requireVerifyUser()(db);
|
243
|
+
const verifyInvites2 = requireVerifyInvites()(db);
|
244
|
+
return {
|
245
|
+
authJwt: authJwt2,
|
246
|
+
authSecret: authSecret2,
|
247
|
+
verifySignUp: verifySignUp2,
|
248
|
+
verifyUser: verifyUser2,
|
249
|
+
verifyInvites: verifyInvites2
|
250
|
+
};
|
251
|
+
};
|
252
|
+
var middlewares = middlewareIndexFactory;
|
253
|
+
export {
|
254
|
+
middlewares as m
|
255
|
+
};
|
@@ -0,0 +1,254 @@
|
|
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
|
+
let token = req.headers["x-access-token"];
|
18
|
+
if (!token && req.cookies.user) {
|
19
|
+
let user = JSON.parse(req.cookies.user);
|
20
|
+
token = user.accessToken;
|
21
|
+
}
|
22
|
+
if (!token) {
|
23
|
+
req.userId = null;
|
24
|
+
if (continueOnFail) {
|
25
|
+
return next();
|
26
|
+
} else {
|
27
|
+
return res.status(401).send({ message: "Unauthorized: No token provided" });
|
28
|
+
}
|
29
|
+
}
|
30
|
+
const decoded = jwt.verify(token, process.env.SECRET_KEY);
|
31
|
+
req.userId = decoded._id;
|
32
|
+
next();
|
33
|
+
} catch (err) {
|
34
|
+
console.log(err);
|
35
|
+
req.userId = null;
|
36
|
+
if (continueOnFail) {
|
37
|
+
next();
|
38
|
+
} else {
|
39
|
+
res.status(401).send({ message: "Unauthorized: Invalid token" });
|
40
|
+
}
|
41
|
+
}
|
42
|
+
};
|
43
|
+
};
|
44
|
+
const checkRole = (roleToCheck) => async (req, res, next) => {
|
45
|
+
try {
|
46
|
+
const user = await User.findById(req.userId).exec();
|
47
|
+
if (!user) {
|
48
|
+
return res.status(404).send({ message: "User Not found." });
|
49
|
+
}
|
50
|
+
const roles = await Role.find({ _id: { $in: user.roles } }).exec();
|
51
|
+
for (let role of roles) {
|
52
|
+
if (role.name === roleToCheck) {
|
53
|
+
next();
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
res.status(403).send({ message: `Require ${roleToCheck} Role!` });
|
58
|
+
} catch (err) {
|
59
|
+
res.status(500).send({ message: err.message });
|
60
|
+
}
|
61
|
+
};
|
62
|
+
const isAdmin = checkRole("admin");
|
63
|
+
const isModerator = checkRole("moderator");
|
64
|
+
return {
|
65
|
+
verifyToken,
|
66
|
+
isAdmin,
|
67
|
+
isModerator
|
68
|
+
};
|
69
|
+
};
|
70
|
+
authJwt = middlewareFactory;
|
71
|
+
return authJwt;
|
72
|
+
}
|
73
|
+
var authSecret;
|
74
|
+
var hasRequiredAuthSecret;
|
75
|
+
function requireAuthSecret() {
|
76
|
+
if (hasRequiredAuthSecret) return authSecret;
|
77
|
+
hasRequiredAuthSecret = 1;
|
78
|
+
const crypto = require$$0$1;
|
79
|
+
const middlewareFactory = () => {
|
80
|
+
const verifySecret = (method, endpoint, secret) => async (req, res, next) => {
|
81
|
+
const requestSignature = req.headers.signature;
|
82
|
+
const signature = crypto.createHmac("sha256", secret).update(method + endpoint).digest("hex");
|
83
|
+
if (signature === requestSignature) {
|
84
|
+
return next();
|
85
|
+
}
|
86
|
+
res.status(403).send("Forbidden");
|
87
|
+
};
|
88
|
+
return { verifySecret };
|
89
|
+
};
|
90
|
+
authSecret = middlewareFactory;
|
91
|
+
return authSecret;
|
92
|
+
}
|
93
|
+
var verifySignUp;
|
94
|
+
var hasRequiredVerifySignUp;
|
95
|
+
function requireVerifySignUp() {
|
96
|
+
if (hasRequiredVerifySignUp) return verifySignUp;
|
97
|
+
hasRequiredVerifySignUp = 1;
|
98
|
+
const middlewareFactory = (db) => {
|
99
|
+
const User = db.user;
|
100
|
+
db.role;
|
101
|
+
const checkDuplicateUsernameOrEmail = async (req, res, next) => {
|
102
|
+
const { type, email, phone } = req.body;
|
103
|
+
console.log(req.body);
|
104
|
+
let query;
|
105
|
+
if (type === "phone" && phone) {
|
106
|
+
query = { phone };
|
107
|
+
}
|
108
|
+
if (type === "email" && email) {
|
109
|
+
query = { email };
|
110
|
+
}
|
111
|
+
try {
|
112
|
+
const user = await User.findOne(query).exec();
|
113
|
+
if (user) {
|
114
|
+
console.log(`USER_ALREADY_REGISTERED`);
|
115
|
+
res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
next();
|
119
|
+
} catch (err) {
|
120
|
+
console.log(err);
|
121
|
+
res.status(500).send({ message: err.message });
|
122
|
+
}
|
123
|
+
};
|
124
|
+
const checkRolesExisted = (req, res, next) => {
|
125
|
+
if (req.body.roles) {
|
126
|
+
for (let i = 0; i < req.body.roles.length; i++) {
|
127
|
+
if (!ROLES.includes(req.body.roles[i])) {
|
128
|
+
console.log(`Failed! Role ${req.body.roles[i]} does not exist!`);
|
129
|
+
res.status(400).send({
|
130
|
+
message: `Failed! Role ${req.body.roles[i]} does not exist!`
|
131
|
+
});
|
132
|
+
return;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
next();
|
137
|
+
};
|
138
|
+
return {
|
139
|
+
checkDuplicateUsernameOrEmail,
|
140
|
+
checkRolesExisted
|
141
|
+
};
|
142
|
+
};
|
143
|
+
verifySignUp = middlewareFactory;
|
144
|
+
return verifySignUp;
|
145
|
+
}
|
146
|
+
var verifyUser;
|
147
|
+
var hasRequiredVerifyUser;
|
148
|
+
function requireVerifyUser() {
|
149
|
+
if (hasRequiredVerifyUser) return verifyUser;
|
150
|
+
hasRequiredVerifyUser = 1;
|
151
|
+
const middlewareFactory = (db) => {
|
152
|
+
const User = db.user;
|
153
|
+
db.role;
|
154
|
+
const checkUserExist = async (req, res, next) => {
|
155
|
+
const { type, email, phone } = req.body;
|
156
|
+
let query;
|
157
|
+
if (type === "phone" && phone) {
|
158
|
+
query = { phone };
|
159
|
+
}
|
160
|
+
if (type === "email" && email) {
|
161
|
+
query = { email };
|
162
|
+
}
|
163
|
+
try {
|
164
|
+
const user = await User.findOne(query).exec();
|
165
|
+
if (!user) {
|
166
|
+
console.log(query);
|
167
|
+
res.status(400).send({ errorCode: "USER_NOT_REGISTERED_YET" });
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
next();
|
171
|
+
} catch (err) {
|
172
|
+
res.status(500).send({ message: err.message });
|
173
|
+
}
|
174
|
+
};
|
175
|
+
return {
|
176
|
+
checkUserExist
|
177
|
+
};
|
178
|
+
};
|
179
|
+
verifyUser = middlewareFactory;
|
180
|
+
return verifyUser;
|
181
|
+
}
|
182
|
+
var verifyInvites;
|
183
|
+
var hasRequiredVerifyInvites;
|
184
|
+
function requireVerifyInvites() {
|
185
|
+
if (hasRequiredVerifyInvites) return verifyInvites;
|
186
|
+
hasRequiredVerifyInvites = 1;
|
187
|
+
const { ObjectId } = require$$0$2;
|
188
|
+
const middlewareFactory = (db) => {
|
189
|
+
const User = db.user;
|
190
|
+
const Invite = db.invite;
|
191
|
+
const Membership = db.membership;
|
192
|
+
const checkInviteExist = async (req, res, next) => {
|
193
|
+
for (let invite of req.body.invites) {
|
194
|
+
let query;
|
195
|
+
if (invite.contact.includes("@")) {
|
196
|
+
query = { invitedEmail: invite.contact };
|
197
|
+
} else {
|
198
|
+
query = { invitedPhone: invite.contact };
|
199
|
+
}
|
200
|
+
query["owner.target"] = req.body.owner.target;
|
201
|
+
const userInvite = await Invite.findOne(query).exec();
|
202
|
+
if (userInvite) {
|
203
|
+
console.log(userInvite);
|
204
|
+
res.status(400).send({ message: "Инвайт c таким email или телефоном уже создан!" });
|
205
|
+
return;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
next();
|
209
|
+
};
|
210
|
+
const checkUsersExist = async (req, res, next) => {
|
211
|
+
for (let invite of req.body.invites) {
|
212
|
+
let query;
|
213
|
+
if (invite.contact.includes("@")) {
|
214
|
+
query = { email: invite.contact };
|
215
|
+
} else {
|
216
|
+
query = { phone: invite.contact };
|
217
|
+
}
|
218
|
+
const user = await User.findOne(query).exec();
|
219
|
+
console.log(req.params);
|
220
|
+
if (user) {
|
221
|
+
const membership = await Membership.findOne({ user: new ObjectId(user._id), "owner.target": req.body.owner.target }).exec();
|
222
|
+
if (membership) {
|
223
|
+
console.log(membership);
|
224
|
+
res.status(400).send({ message: "Пользователь с таким email или телефоном уже добавлен в организацию!" });
|
225
|
+
return;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
}
|
229
|
+
next();
|
230
|
+
};
|
231
|
+
return {
|
232
|
+
checkInviteExist,
|
233
|
+
checkUsersExist
|
234
|
+
};
|
235
|
+
};
|
236
|
+
verifyInvites = middlewareFactory;
|
237
|
+
return verifyInvites;
|
238
|
+
}
|
239
|
+
const middlewareIndexFactory = (db) => {
|
240
|
+
const authJwt2 = requireAuthJwt()(db);
|
241
|
+
const authSecret2 = requireAuthSecret()();
|
242
|
+
const verifySignUp2 = requireVerifySignUp()(db);
|
243
|
+
const verifyUser2 = requireVerifyUser()(db);
|
244
|
+
const verifyInvites2 = requireVerifyInvites()(db);
|
245
|
+
return {
|
246
|
+
authJwt: authJwt2,
|
247
|
+
authSecret: authSecret2,
|
248
|
+
verifySignUp: verifySignUp2,
|
249
|
+
verifyUser: verifyUser2,
|
250
|
+
verifyInvites: verifyInvites2
|
251
|
+
};
|
252
|
+
};
|
253
|
+
var middlewares = middlewareIndexFactory;
|
254
|
+
exports.middlewares = middlewares;
|