@ozdao/prometheus-framework 0.2.48 → 0.2.51
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth.server.js +27 -25
- package/dist/auth.server.mjs +27 -25
- 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-3981e903.mjs +217 -0
- package/dist/index-4eecfdb9.js +216 -0
- package/dist/main-203b36b6.mjs +13628 -0
- package/dist/main-_b1_i8mt.mjs +13606 -0
- package/dist/main-a7ae4ce5.js +91 -0
- package/dist/main-uiQFxEks.js +91 -0
- package/dist/main.css +1 -1
- package/dist/middlewares.server.js +1 -1
- package/dist/middlewares.server.mjs +1 -1
- package/dist/node_modules/vue-select/dist/vue-select.es.cjs +1 -3
- package/dist/node_modules/vue-select/dist/vue-select.es.js +49 -645
- package/dist/organizations.server.js +35 -43
- package/dist/organizations.server.mjs +35 -43
- package/dist/products.server.js +107 -24
- package/dist/products.server.mjs +107 -24
- package/dist/prometheus-framework/src/components/Button/Button.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Button/Button.vue.js +2 -225
- package/dist/prometheus-framework/src/components/Button/Button.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Button/Button.vue2.js +225 -2
- package/dist/prometheus-framework/src/components/Checkbox/Checkbox.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Checkbox/Checkbox.vue.js +61 -2
- package/dist/prometheus-framework/src/components/Checkbox/Checkbox.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Checkbox/Checkbox.vue2.js +2 -61
- package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Field/Field.vue.js +2 -76
- package/dist/prometheus-framework/src/components/Field/Field.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Field/Field.vue2.js +76 -2
- 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/SelectMulti/SelectMulti.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/SelectMulti/SelectMulti.vue.js +6 -6
- package/dist/prometheus-framework/src/components/Tab/Tab.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Tab/Tab.vue.js +2 -44
- package/dist/prometheus-framework/src/components/Tab/Tab.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Tab/Tab.vue2.js +44 -2
- 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 +3 -3
- 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 +3 -3
- 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 +44 -32
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- package/dist/prometheus-framework/src/modules/auth/store/auth.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/store/auth.js +45 -44
- package/dist/prometheus-framework/src/modules/auth/store/invites.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/store/invites.js +5 -5
- 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 +1 -1
- 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/constructor/components/elements/Embed.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/elements/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/Events.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/Events.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 +2 -2
- package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.js +2 -2
- 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 +1 -1
- package/dist/prometheus-framework/src/modules/globals/store/globals.cjs +1 -1
- package/dist/prometheus-framework/src/modules/globals/store/globals.js +22 -21
- 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 +3 -3
- package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.js +11 -2
- package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.js +2 -11
- package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormOrderDetails.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormOrderDetails.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 +17 -17
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.js +49 -42
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/User.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/User.vue.js +48 -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 +38 -37
- 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 +249 -61
- 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 +78 -45
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +160 -86
- package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.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 +2 -2
- 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 +52 -54
- 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 +20 -26
- package/dist/prometheus-framework/src/modules/organizations/organizations.client.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/organizations.client.js +40 -46
- package/dist/prometheus-framework/src/modules/organizations/store/departments.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/store/departments.js +34 -30
- package/dist/prometheus-framework/src/modules/organizations/store/memberships.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/store/memberships.js +30 -28
- 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 +18 -18
- 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/EditLeftover.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/Product.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/Product.vue.js +33 -28
- 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 +123 -113
- package/dist/prometheus-framework/src/modules/products/components/pages/ProductsBackoffice.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/ProductsBackoffice.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/products/components/sections/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/products/store/products.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/store/products.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 +1 -1
- 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/ProfileBlogposts.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/users/components/pages/ProfileBlogposts.vue.js +1 -1
- 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 +3 -3
- package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.js +1 -1
- package/dist/prometheus-framework.cjs.js +1 -1
- package/dist/prometheus-framework.es.js +1 -1
- package/dist/reports.server.js +1 -1
- package/dist/reports.server.mjs +1 -1
- package/dist/style.css +1 -1
- package/dist/web-7p76PGnO.mjs +55 -0
- package/dist/web-c63f0ecc.js +1 -0
- package/dist/web-d8173758.mjs +55 -0
- package/dist/web-dn8vgptQ.js +1 -0
- package/package.json +1 -1
- package/src/components/SelectMulti/SelectMulti.vue +1 -1
- package/src/modules/auth/components/pages/Invite.vue +17 -6
- package/src/modules/auth/controllers/auth.controller.js +24 -16
- package/src/modules/auth/controllers/invites.controller.js +17 -8
- package/src/modules/auth/store/auth.js +8 -1
- package/src/modules/auth/store/invites.js +1 -0
- package/src/modules/globals/store/globals.js +5 -1
- package/src/modules/landing/components/blocks/MapBlock.vue +37 -0
- package/src/modules/landing/components/pages/404.vue +3 -0
- package/src/modules/landing/components/pages/Governance.vue +155 -0
- package/src/modules/landing/components/pages/Home.vue +52 -0
- package/src/modules/landing/components/pages/Hotel.vue +54 -0
- package/src/modules/landing/components/pages/Page.vue +184 -0
- package/src/modules/landing/components/sections/AboutSection.vue +69 -0
- package/src/modules/landing/components/sections/Examples.vue +90 -0
- package/src/modules/landing/components/sections/FeatureSection.vue +80 -0
- package/src/modules/landing/components/sections/GiftSection.vue +63 -0
- package/src/modules/landing/components/sections/HeroSection.vue +74 -0
- package/src/modules/landing/components/sections/HowItWorksSection.vue +88 -0
- package/src/modules/landing/components/sections/HowToBuyWDR.vue +131 -0
- package/src/modules/landing/components/sections/InstagramSection.vue +181 -0
- package/src/modules/landing/components/sections/MapSection.vue +91 -0
- package/src/modules/landing/components/sections/SectionsSection.vue +69 -0
- package/src/modules/landing/components/sections/SliderFeatures.vue +131 -0
- package/src/modules/landing/components/sections/WhatIsWDRSection.vue +116 -0
- package/src/modules/landing/router/landing.js +34 -0
- package/src/modules/middlewares/server/verifySignUp.js +4 -0
- package/src/modules/mobile/components/BottomNavigation/BottomNavigation.vue +86 -0
- package/src/modules/mobile/components/BottomSheet/BottomSheet.vue +86 -0
- package/src/modules/mobile/components/NavigationBar/NavigationBar.vue +132 -0
- package/src/modules/mobile/components/Walkthrough/Walkthrough.vue +195 -0
- package/src/modules/organizations/components/blocks/CardDepartment.vue +3 -3
- package/src/modules/organizations/components/blocks/DepartmentMemberModify.vue +52 -44
- package/src/modules/organizations/components/blocks/User.vue +42 -10
- package/src/modules/organizations/components/pages/Department.vue +7 -6
- package/src/modules/organizations/components/pages/DepartmentEdit.vue +110 -134
- package/src/modules/organizations/components/pages/Members.vue +85 -26
- package/src/modules/organizations/components/pages/Organization.vue +59 -4
- package/src/modules/organizations/components/sections/MembersAdd.vue +27 -34
- package/src/modules/organizations/components/sections/Organizations.vue +0 -1
- package/src/modules/organizations/controllers/memberships.controller.js +33 -26
- package/src/modules/organizations/controllers/organizations.controller.js +1 -1
- package/src/modules/organizations/models/department.model.js +0 -19
- package/src/modules/organizations/models/membership.model.js +4 -0
- package/src/modules/organizations/organizations.client.js +1 -6
- package/src/modules/organizations/store/departments.js +48 -44
- package/src/modules/organizations/store/memberships.js +11 -3
- package/src/modules/products/components/blocks/CardPosition.vue +2 -2
- package/src/modules/products/components/pages/Product.vue +6 -1
- package/src/modules/products/components/pages/ProductEdit.vue +48 -28
- package/src/modules/products/controllers/products.controller.js +99 -33
- package/src/modules/products/models/product.model.js +16 -1
- package/src/modules/products/store/products.js +1 -1
- package/src/modules/users/components/pages/ProfileOrganizations.vue +41 -7
- package/src/styles/layout.scss +1 -1
- package/src/modules/organizations/components/sections/FeedDepartments.vue +0 -64
- package/src/modules/organizations/components/sections/MembersList.vue +0 -85
- package/src/modules/organizations/store/invites.js +0 -93
@@ -0,0 +1,216 @@
|
|
1
|
+
"use strict";
|
2
|
+
const require$$0 = require("jsonwebtoken");
|
3
|
+
const require$$0$1 = require("mongodb");
|
4
|
+
const jwt = require$$0;
|
5
|
+
const middlewareFactory$4 = (db) => {
|
6
|
+
const User = db.user;
|
7
|
+
const Role = db.role;
|
8
|
+
const verifyToken = async (req, res, next) => {
|
9
|
+
try {
|
10
|
+
console.log(req.cookies);
|
11
|
+
let user = JSON.parse(req.cookies.user);
|
12
|
+
let token = req.headers["x-access-token"] || user.accessToken;
|
13
|
+
if (!token) {
|
14
|
+
return res.status(403).send({ message: "No token provided!" });
|
15
|
+
}
|
16
|
+
const decoded = jwt.verify(token, process.env.SECRET_KEY);
|
17
|
+
req.userId = decoded._id;
|
18
|
+
console.log("success");
|
19
|
+
next();
|
20
|
+
} catch (err) {
|
21
|
+
console.log(err);
|
22
|
+
return res.status(401).send({ message: "Unauthorized!" });
|
23
|
+
}
|
24
|
+
};
|
25
|
+
const checkRole = (roleToCheck) => async (req, res, next) => {
|
26
|
+
try {
|
27
|
+
const user = await User.findById(req.userId).exec();
|
28
|
+
if (!user) {
|
29
|
+
return res.status(404).send({ message: "User Not found." });
|
30
|
+
}
|
31
|
+
const roles = await Role.find({ _id: { $in: user.roles } }).exec();
|
32
|
+
for (let role of roles) {
|
33
|
+
if (role.name === roleToCheck) {
|
34
|
+
next();
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
res.status(403).send({ message: `Require ${roleToCheck} Role!` });
|
39
|
+
} catch (err) {
|
40
|
+
res.status(500).send({ message: err.message });
|
41
|
+
}
|
42
|
+
};
|
43
|
+
const isAdmin = checkRole("admin");
|
44
|
+
const isModerator = checkRole("moderator");
|
45
|
+
return {
|
46
|
+
verifyToken,
|
47
|
+
isAdmin,
|
48
|
+
isModerator
|
49
|
+
};
|
50
|
+
};
|
51
|
+
var authJwt = middlewareFactory$4;
|
52
|
+
const middlewareFactory$3 = (db) => {
|
53
|
+
const User = db.user;
|
54
|
+
db.role;
|
55
|
+
const checkDuplicateUsernameOrEmail = async (req, res, next) => {
|
56
|
+
const { type, email, phone } = req.body;
|
57
|
+
console.log(req.body);
|
58
|
+
let query;
|
59
|
+
if (type === "phone" && phone) {
|
60
|
+
query = { phone };
|
61
|
+
}
|
62
|
+
if (type === "email" && email) {
|
63
|
+
query = { email };
|
64
|
+
}
|
65
|
+
try {
|
66
|
+
const user = await User.findOne(query).exec();
|
67
|
+
if (user) {
|
68
|
+
console.log(`USER_ALREADY_REGISTERED`);
|
69
|
+
res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
next();
|
73
|
+
} catch (err) {
|
74
|
+
console.log(err);
|
75
|
+
res.status(500).send({ message: err.message });
|
76
|
+
}
|
77
|
+
};
|
78
|
+
const checkRolesExisted = (req, res, next) => {
|
79
|
+
if (req.body.roles) {
|
80
|
+
for (let i = 0; i < req.body.roles.length; i++) {
|
81
|
+
if (!ROLES.includes(req.body.roles[i])) {
|
82
|
+
console.log(`Failed! Role ${req.body.roles[i]} does not exist!`);
|
83
|
+
res.status(400).send({
|
84
|
+
message: `Failed! Role ${req.body.roles[i]} does not exist!`
|
85
|
+
});
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
next();
|
91
|
+
};
|
92
|
+
return {
|
93
|
+
checkDuplicateUsernameOrEmail,
|
94
|
+
checkRolesExisted
|
95
|
+
};
|
96
|
+
};
|
97
|
+
var verifySignUp = middlewareFactory$3;
|
98
|
+
const middlewareFactory$2 = (db) => {
|
99
|
+
const User = db.user;
|
100
|
+
db.role;
|
101
|
+
const checkUserExist = async (req, res, next) => {
|
102
|
+
const { type, email, phone } = 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(query);
|
114
|
+
res.status(400).send({ errorCode: "USER_NOT_REGISTERED_YET" });
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
next();
|
118
|
+
} catch (err) {
|
119
|
+
res.status(500).send({ message: err.message });
|
120
|
+
}
|
121
|
+
};
|
122
|
+
return {
|
123
|
+
checkUserExist
|
124
|
+
};
|
125
|
+
};
|
126
|
+
var verifyUser = middlewareFactory$2;
|
127
|
+
const { ObjectId } = require$$0$1;
|
128
|
+
const middlewareFactory$1 = (db) => {
|
129
|
+
const User = db.user;
|
130
|
+
const Invite = db.invite;
|
131
|
+
const Membership = db.membership;
|
132
|
+
const checkInviteExist = async (req, res, next) => {
|
133
|
+
for (let invite of req.body) {
|
134
|
+
let query;
|
135
|
+
if (invite.contact.includes("@")) {
|
136
|
+
query = { invitedEmail: invite.contact };
|
137
|
+
} else {
|
138
|
+
query = { invitedPhone: invite.contact };
|
139
|
+
}
|
140
|
+
query.organization = req.params._id;
|
141
|
+
const userInvite = await Invite.findOne(query).exec();
|
142
|
+
if (userInvite) {
|
143
|
+
console.log(userInvite);
|
144
|
+
res.status(400).send({ message: "Инвайт c таким email или телефоном уже создан!" });
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
next();
|
149
|
+
};
|
150
|
+
const checkUsersExist = async (req, res, next) => {
|
151
|
+
for (let invite of req.body) {
|
152
|
+
let query;
|
153
|
+
if (invite.contact.includes("@")) {
|
154
|
+
query = { email: invite.contact };
|
155
|
+
} else {
|
156
|
+
query = { phone: invite.contact };
|
157
|
+
}
|
158
|
+
const user = await User.findOne(query).exec();
|
159
|
+
console.log(req.params);
|
160
|
+
if (user) {
|
161
|
+
const membership = await Membership.findOne({ user: new ObjectId(user._id), organization: req.params._id }).exec();
|
162
|
+
if (membership) {
|
163
|
+
console.log(membership);
|
164
|
+
res.status(400).send({ message: "Пользователь с таким email или телефоном уже добавлен в организацию!" });
|
165
|
+
return;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
next();
|
170
|
+
};
|
171
|
+
return {
|
172
|
+
checkInviteExist,
|
173
|
+
checkUsersExist
|
174
|
+
};
|
175
|
+
};
|
176
|
+
var verifyInvites = middlewareFactory$1;
|
177
|
+
const middlewareFactory = (db) => {
|
178
|
+
const Category = db.category;
|
179
|
+
const checkCategoryExistOrNot = async (req, res, next) => {
|
180
|
+
try {
|
181
|
+
const category = await Category.findOne({ url: req.body.url });
|
182
|
+
if (category) {
|
183
|
+
res.status(400).send({ message: "Failed! Category with this URL is already in use!" });
|
184
|
+
return;
|
185
|
+
}
|
186
|
+
next();
|
187
|
+
} catch (err) {
|
188
|
+
res.status(500).send({ message: err });
|
189
|
+
}
|
190
|
+
};
|
191
|
+
return {
|
192
|
+
checkCategoryExistOrNot
|
193
|
+
};
|
194
|
+
};
|
195
|
+
var verifyCategory = middlewareFactory;
|
196
|
+
const middlewareIndexFactory = (db) => {
|
197
|
+
const authJwt$1 = authJwt(db);
|
198
|
+
const verifySignUp$1 = verifySignUp(db);
|
199
|
+
const verifyUser$1 = verifyUser(db);
|
200
|
+
const verifyInvites$1 = verifyInvites(db);
|
201
|
+
const verifyCategory$1 = verifyCategory(db);
|
202
|
+
return {
|
203
|
+
authJwt: authJwt$1,
|
204
|
+
verifySignUp: verifySignUp$1,
|
205
|
+
verifyUser: verifyUser$1,
|
206
|
+
verifyInvites: verifyInvites$1,
|
207
|
+
verifyCategory: verifyCategory$1
|
208
|
+
};
|
209
|
+
};
|
210
|
+
var server = middlewareIndexFactory;
|
211
|
+
exports.authJwt = authJwt;
|
212
|
+
exports.server = server;
|
213
|
+
exports.verifyCategory = verifyCategory;
|
214
|
+
exports.verifyInvites = verifyInvites;
|
215
|
+
exports.verifySignUp = verifySignUp;
|
216
|
+
exports.verifyUser = verifyUser;
|