@ozdao/prometheus-framework 0.2.23 → 0.2.24
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth.server.js +9 -2
- package/dist/auth.server.mjs +9 -2
- 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-05aa7cae.js +213 -0
- package/dist/index-d5066b82.mjs +214 -0
- package/dist/middlewares.server.js +1 -1
- package/dist/middlewares.server.mjs +1 -1
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue.js +49 -2
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue2.js +2 -49
- package/dist/prometheus-framework/src/components/Popup/Popup.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Popup/Popup.vue.js +2 -72
- package/dist/prometheus-framework/src/components/Popup/Popup.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Popup/Popup.vue2.js +72 -2
- package/dist/prometheus-framework/src/components/Select/Select.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Select/Select.vue.js +2 -78
- package/dist/prometheus-framework/src/components/Select/Select.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Select/Select.vue2.js +78 -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 +29 -25
- package/dist/prometheus-framework/src/modules/auth/store/twofa.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/store/twofa.js +12 -11
- 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/CreateBlogPost.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.cjs +1 -4
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.js +2 -62
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.cjs +4 -1
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.js +62 -2
- package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.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 +2 -2
- 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 +3 -3
- 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 +1 -1
- 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 +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 +1 -1
- 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 +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 +2 -2
- 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 +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 +2 -2
- package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +1 -1
- 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 +1 -1
- 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 +3 -3
- 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 +2 -2
- 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 +1 -1
- package/dist/reports.server.js +1 -1
- package/dist/reports.server.mjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/modules/auth/components/pages/EnterCode.vue +81 -62
- package/src/modules/auth/routes/twofa.routes.js +9 -1
- package/src/modules/auth/store/twofa.js +4 -1
- package/src/modules/middlewares/server/verifyUser.js +1 -0
package/dist/auth.server.js
CHANGED
@@ -7,7 +7,7 @@ const require$$3 = require("uuidv4");
|
|
7
7
|
const require$$1 = require("node-fetch");
|
8
8
|
const require$$2 = require("jwk-to-pem");
|
9
9
|
const mailing = require("./mailing-02321795.js");
|
10
|
-
const index = require("./index-
|
10
|
+
const index = require("./index-05aa7cae.js");
|
11
11
|
require("dotenv");
|
12
12
|
require("nodemailer");
|
13
13
|
require("axios");
|
@@ -450,7 +450,7 @@ const controllerFactory = twofa_controller;
|
|
450
450
|
const middlewareFactory = index.server;
|
451
451
|
var twofa_routes = function(app, db) {
|
452
452
|
const controller = controllerFactory();
|
453
|
-
const { verifySignUp } = middlewareFactory(db);
|
453
|
+
const { verifySignUp, verifyUser } = middlewareFactory(db);
|
454
454
|
app.use(function(req, res, next) {
|
455
455
|
res.header(
|
456
456
|
"Access-Control-Allow-Headers",
|
@@ -466,6 +466,13 @@ var twofa_routes = function(app, db) {
|
|
466
466
|
],
|
467
467
|
controller.sendcode
|
468
468
|
);
|
469
|
+
app.post(
|
470
|
+
"/api/twofa/sendcodereset",
|
471
|
+
[
|
472
|
+
verifyUser.checkUserExist
|
473
|
+
],
|
474
|
+
controller.sendcode
|
475
|
+
);
|
469
476
|
};
|
470
477
|
var role_model = (mongoose) => {
|
471
478
|
const Role = mongoose.model(
|
package/dist/auth.server.mjs
CHANGED
@@ -6,7 +6,7 @@ import require$$3 from "uuidv4";
|
|
6
6
|
import require$$1 from "node-fetch";
|
7
7
|
import require$$2 from "jwk-to-pem";
|
8
8
|
import { m as mailing } from "./mailing-eb3bd084.mjs";
|
9
|
-
import { s as server } from "./index-
|
9
|
+
import { s as server } from "./index-d5066b82.mjs";
|
10
10
|
import "dotenv";
|
11
11
|
import "nodemailer";
|
12
12
|
import "axios";
|
@@ -449,7 +449,7 @@ const controllerFactory = twofa_controller;
|
|
449
449
|
const middlewareFactory = server;
|
450
450
|
var twofa_routes = function(app, db) {
|
451
451
|
const controller = controllerFactory();
|
452
|
-
const { verifySignUp } = middlewareFactory(db);
|
452
|
+
const { verifySignUp, verifyUser } = middlewareFactory(db);
|
453
453
|
app.use(function(req, res, next) {
|
454
454
|
res.header(
|
455
455
|
"Access-Control-Allow-Headers",
|
@@ -465,6 +465,13 @@ var twofa_routes = function(app, db) {
|
|
465
465
|
],
|
466
466
|
controller.sendcode
|
467
467
|
);
|
468
|
+
app.post(
|
469
|
+
"/api/twofa/sendcodereset",
|
470
|
+
[
|
471
|
+
verifyUser.checkUserExist
|
472
|
+
],
|
473
|
+
controller.sendcode
|
474
|
+
);
|
468
475
|
};
|
469
476
|
var role_model = (mongoose) => {
|
470
477
|
const Role = mongoose.model(
|
package/dist/community.server.js
CHANGED
@@ -4,7 +4,7 @@ const require$$0 = require("mongoose");
|
|
4
4
|
const metadata_schema = require("./metadata.schema-e4fe5c57.js");
|
5
5
|
require("util");
|
6
6
|
require("uuid");
|
7
|
-
const index = require("./index-
|
7
|
+
const index = require("./index-05aa7cae.js");
|
8
8
|
require("jsonwebtoken");
|
9
9
|
require("mongodb");
|
10
10
|
function getPeriodConditions(period) {
|
@@ -3,7 +3,7 @@ import require$$0 from "mongoose";
|
|
3
3
|
import { q as queryProcessor$3, c as common_schema, e as engagement_schema, o as ownership_schema, m as metadata_schema } from "./metadata.schema-a539dd65.mjs";
|
4
4
|
import "util";
|
5
5
|
import "uuid";
|
6
|
-
import { s as server$1 } from "./index-
|
6
|
+
import { s as server$1 } from "./index-d5066b82.mjs";
|
7
7
|
import "jsonwebtoken";
|
8
8
|
import "mongodb";
|
9
9
|
function getPeriodConditions(period) {
|
package/dist/events.server.js
CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const _commonjsHelpers = require("./_commonjsHelpers-3b53548e.js");
|
4
4
|
const require$$0 = require("mongoose");
|
5
5
|
const metadata_schema = require("./metadata.schema-e4fe5c57.js");
|
6
|
-
const index = require("./index-
|
6
|
+
const index = require("./index-05aa7cae.js");
|
7
7
|
require("jsonwebtoken");
|
8
8
|
require("mongodb");
|
9
9
|
const ObjectId = require$$0.Types.ObjectId;
|
package/dist/events.server.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-83b1d755.mjs";
|
2
2
|
import require$$0 from "mongoose";
|
3
3
|
import { q as queryProcessor$2, c as common_schema, e as engagement_schema, o as ownership_schema, m as metadata_schema } from "./metadata.schema-a539dd65.mjs";
|
4
|
-
import { s as server$1 } from "./index-
|
4
|
+
import { s as server$1 } from "./index-d5066b82.mjs";
|
5
5
|
import "jsonwebtoken";
|
6
6
|
import "mongodb";
|
7
7
|
const ObjectId = require$$0.Types.ObjectId;
|
package/dist/files.server.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
const _commonjsHelpers = require("./_commonjsHelpers-3b53548e.js");
|
3
|
-
const index = require("./index-
|
3
|
+
const index = require("./index-05aa7cae.js");
|
4
4
|
const require$$0 = require("sharp");
|
5
5
|
const require$$1 = require("fs");
|
6
6
|
const require$$2 = require("path");
|
package/dist/files.server.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-83b1d755.mjs";
|
2
|
-
import { s as server$1 } from "./index-
|
2
|
+
import { s as server$1 } from "./index-d5066b82.mjs";
|
3
3
|
import require$$0 from "sharp";
|
4
4
|
import require$$1 from "fs";
|
5
5
|
import require$$2 from "path";
|
package/dist/gallery.server.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
const _commonjsHelpers = require("./_commonjsHelpers-3b53548e.js");
|
3
3
|
const require$$2 = require("path");
|
4
|
-
const index = require("./index-
|
4
|
+
const index = require("./index-05aa7cae.js");
|
5
5
|
require("jsonwebtoken");
|
6
6
|
require("mongodb");
|
7
7
|
const path = require$$2;
|
package/dist/gallery.server.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-83b1d755.mjs";
|
2
2
|
import require$$2 from "path";
|
3
|
-
import { s as server } from "./index-
|
3
|
+
import { s as server } from "./index-d5066b82.mjs";
|
4
4
|
import "jsonwebtoken";
|
5
5
|
import "mongodb";
|
6
6
|
const path = require$$2;
|
@@ -0,0 +1,213 @@
|
|
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
|
+
let query;
|
58
|
+
if (type === "phone" && phone) {
|
59
|
+
query = { phone };
|
60
|
+
}
|
61
|
+
if (type === "email" && email) {
|
62
|
+
query = { email };
|
63
|
+
}
|
64
|
+
try {
|
65
|
+
const user = await User.findOne(query).exec();
|
66
|
+
if (user) {
|
67
|
+
res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
next();
|
71
|
+
} catch (err) {
|
72
|
+
console.log(err);
|
73
|
+
res.status(500).send({ message: err.message });
|
74
|
+
}
|
75
|
+
};
|
76
|
+
const checkRolesExisted = (req, res, next) => {
|
77
|
+
if (req.body.roles) {
|
78
|
+
for (let i = 0; i < req.body.roles.length; i++) {
|
79
|
+
if (!ROLES.includes(req.body.roles[i])) {
|
80
|
+
res.status(400).send({
|
81
|
+
message: `Failed! Role ${req.body.roles[i]} does not exist!`
|
82
|
+
});
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
next();
|
88
|
+
};
|
89
|
+
return {
|
90
|
+
checkDuplicateUsernameOrEmail,
|
91
|
+
checkRolesExisted
|
92
|
+
};
|
93
|
+
};
|
94
|
+
var verifySignUp = middlewareFactory$3;
|
95
|
+
const middlewareFactory$2 = (db) => {
|
96
|
+
const User = db.user;
|
97
|
+
db.role;
|
98
|
+
const checkUserExist = async (req, res, next) => {
|
99
|
+
const { type, email, phone } = req.body;
|
100
|
+
let query;
|
101
|
+
if (type === "phone" && phone) {
|
102
|
+
query = { phone };
|
103
|
+
}
|
104
|
+
if (type === "email" && email) {
|
105
|
+
query = { email };
|
106
|
+
}
|
107
|
+
try {
|
108
|
+
const user = await User.findOne(query).exec();
|
109
|
+
if (!user) {
|
110
|
+
console.log(query);
|
111
|
+
res.status(400).send({ errorCode: "USER_NOT_REGISTERED_YET" });
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
next();
|
115
|
+
} catch (err) {
|
116
|
+
res.status(500).send({ message: err.message });
|
117
|
+
}
|
118
|
+
};
|
119
|
+
return {
|
120
|
+
checkUserExist
|
121
|
+
};
|
122
|
+
};
|
123
|
+
var verifyUser = middlewareFactory$2;
|
124
|
+
const { ObjectId } = require$$0$1;
|
125
|
+
const middlewareFactory$1 = (db) => {
|
126
|
+
const User = db.user;
|
127
|
+
const Invite = db.invite;
|
128
|
+
const Membership = db.membership;
|
129
|
+
const checkInviteExist = async (req, res, next) => {
|
130
|
+
for (let invite of req.body) {
|
131
|
+
let query;
|
132
|
+
if (invite.contact.includes("@")) {
|
133
|
+
query = { invitedEmail: invite.contact };
|
134
|
+
} else {
|
135
|
+
query = { invitedPhone: invite.contact };
|
136
|
+
}
|
137
|
+
query.organization = req.params._id;
|
138
|
+
const userInvite = await Invite.findOne(query).exec();
|
139
|
+
if (userInvite) {
|
140
|
+
console.log(userInvite);
|
141
|
+
res.status(400).send({ message: "Инвайт c таким email или телефоном уже создан!" });
|
142
|
+
return;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
next();
|
146
|
+
};
|
147
|
+
const checkUsersExist = async (req, res, next) => {
|
148
|
+
for (let invite of req.body) {
|
149
|
+
let query;
|
150
|
+
if (invite.contact.includes("@")) {
|
151
|
+
query = { email: invite.contact };
|
152
|
+
} else {
|
153
|
+
query = { phone: invite.contact };
|
154
|
+
}
|
155
|
+
const user = await User.findOne(query).exec();
|
156
|
+
console.log(req.params);
|
157
|
+
if (user) {
|
158
|
+
const membership = await Membership.findOne({ user: new ObjectId(user._id), organization: req.params._id }).exec();
|
159
|
+
if (membership) {
|
160
|
+
console.log(membership);
|
161
|
+
res.status(400).send({ message: "Пользователь с таким email или телефоном уже добавлен в организацию!" });
|
162
|
+
return;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
166
|
+
next();
|
167
|
+
};
|
168
|
+
return {
|
169
|
+
checkInviteExist,
|
170
|
+
checkUsersExist
|
171
|
+
};
|
172
|
+
};
|
173
|
+
var verifyInvites = middlewareFactory$1;
|
174
|
+
const middlewareFactory = (db) => {
|
175
|
+
const Category = db.category;
|
176
|
+
const checkCategoryExistOrNot = async (req, res, next) => {
|
177
|
+
try {
|
178
|
+
const category = await Category.findOne({ url: req.body.url });
|
179
|
+
if (category) {
|
180
|
+
res.status(400).send({ message: "Failed! Category with this URL is already in use!" });
|
181
|
+
return;
|
182
|
+
}
|
183
|
+
next();
|
184
|
+
} catch (err) {
|
185
|
+
res.status(500).send({ message: err });
|
186
|
+
}
|
187
|
+
};
|
188
|
+
return {
|
189
|
+
checkCategoryExistOrNot
|
190
|
+
};
|
191
|
+
};
|
192
|
+
var verifyCategory = middlewareFactory;
|
193
|
+
const middlewareIndexFactory = (db) => {
|
194
|
+
const authJwt$1 = authJwt(db);
|
195
|
+
const verifySignUp$1 = verifySignUp(db);
|
196
|
+
const verifyUser$1 = verifyUser(db);
|
197
|
+
const verifyInvites$1 = verifyInvites(db);
|
198
|
+
const verifyCategory$1 = verifyCategory(db);
|
199
|
+
return {
|
200
|
+
authJwt: authJwt$1,
|
201
|
+
verifySignUp: verifySignUp$1,
|
202
|
+
verifyUser: verifyUser$1,
|
203
|
+
verifyInvites: verifyInvites$1,
|
204
|
+
verifyCategory: verifyCategory$1
|
205
|
+
};
|
206
|
+
};
|
207
|
+
var server = middlewareIndexFactory;
|
208
|
+
exports.authJwt = authJwt;
|
209
|
+
exports.server = server;
|
210
|
+
exports.verifyCategory = verifyCategory;
|
211
|
+
exports.verifyInvites = verifyInvites;
|
212
|
+
exports.verifySignUp = verifySignUp;
|
213
|
+
exports.verifyUser = verifyUser;
|
@@ -0,0 +1,214 @@
|
|
1
|
+
import require$$0 from "jsonwebtoken";
|
2
|
+
import require$$0$1 from "mongodb";
|
3
|
+
const jwt = require$$0;
|
4
|
+
const middlewareFactory$4 = (db) => {
|
5
|
+
const User = db.user;
|
6
|
+
const Role = db.role;
|
7
|
+
const verifyToken = async (req, res, next) => {
|
8
|
+
try {
|
9
|
+
console.log(req.cookies);
|
10
|
+
let user = JSON.parse(req.cookies.user);
|
11
|
+
let token = req.headers["x-access-token"] || user.accessToken;
|
12
|
+
if (!token) {
|
13
|
+
return res.status(403).send({ message: "No token provided!" });
|
14
|
+
}
|
15
|
+
const decoded = jwt.verify(token, process.env.SECRET_KEY);
|
16
|
+
req.userId = decoded.id;
|
17
|
+
console.log("success");
|
18
|
+
next();
|
19
|
+
} catch (err) {
|
20
|
+
console.log(err);
|
21
|
+
return res.status(401).send({ message: "Unauthorized!" });
|
22
|
+
}
|
23
|
+
};
|
24
|
+
const checkRole = (roleToCheck) => async (req, res, next) => {
|
25
|
+
try {
|
26
|
+
const user = await User.findById(req.userId).exec();
|
27
|
+
if (!user) {
|
28
|
+
return res.status(404).send({ message: "User Not found." });
|
29
|
+
}
|
30
|
+
const roles = await Role.find({ _id: { $in: user.roles } }).exec();
|
31
|
+
for (let role of roles) {
|
32
|
+
if (role.name === roleToCheck) {
|
33
|
+
next();
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
res.status(403).send({ message: `Require ${roleToCheck} Role!` });
|
38
|
+
} catch (err) {
|
39
|
+
res.status(500).send({ message: err.message });
|
40
|
+
}
|
41
|
+
};
|
42
|
+
const isAdmin = checkRole("admin");
|
43
|
+
const isModerator = checkRole("moderator");
|
44
|
+
return {
|
45
|
+
verifyToken,
|
46
|
+
isAdmin,
|
47
|
+
isModerator
|
48
|
+
};
|
49
|
+
};
|
50
|
+
var authJwt = middlewareFactory$4;
|
51
|
+
const middlewareFactory$3 = (db) => {
|
52
|
+
const User = db.user;
|
53
|
+
db.role;
|
54
|
+
const checkDuplicateUsernameOrEmail = async (req, res, next) => {
|
55
|
+
const { type, email, phone } = req.body;
|
56
|
+
let query;
|
57
|
+
if (type === "phone" && phone) {
|
58
|
+
query = { phone };
|
59
|
+
}
|
60
|
+
if (type === "email" && email) {
|
61
|
+
query = { email };
|
62
|
+
}
|
63
|
+
try {
|
64
|
+
const user = await User.findOne(query).exec();
|
65
|
+
if (user) {
|
66
|
+
res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
next();
|
70
|
+
} catch (err) {
|
71
|
+
console.log(err);
|
72
|
+
res.status(500).send({ message: err.message });
|
73
|
+
}
|
74
|
+
};
|
75
|
+
const checkRolesExisted = (req, res, next) => {
|
76
|
+
if (req.body.roles) {
|
77
|
+
for (let i = 0; i < req.body.roles.length; i++) {
|
78
|
+
if (!ROLES.includes(req.body.roles[i])) {
|
79
|
+
res.status(400).send({
|
80
|
+
message: `Failed! Role ${req.body.roles[i]} does not exist!`
|
81
|
+
});
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
next();
|
87
|
+
};
|
88
|
+
return {
|
89
|
+
checkDuplicateUsernameOrEmail,
|
90
|
+
checkRolesExisted
|
91
|
+
};
|
92
|
+
};
|
93
|
+
var verifySignUp = middlewareFactory$3;
|
94
|
+
const middlewareFactory$2 = (db) => {
|
95
|
+
const User = db.user;
|
96
|
+
db.role;
|
97
|
+
const checkUserExist = async (req, res, next) => {
|
98
|
+
const { type, email, phone } = req.body;
|
99
|
+
let query;
|
100
|
+
if (type === "phone" && phone) {
|
101
|
+
query = { phone };
|
102
|
+
}
|
103
|
+
if (type === "email" && email) {
|
104
|
+
query = { email };
|
105
|
+
}
|
106
|
+
try {
|
107
|
+
const user = await User.findOne(query).exec();
|
108
|
+
if (!user) {
|
109
|
+
console.log(query);
|
110
|
+
res.status(400).send({ errorCode: "USER_NOT_REGISTERED_YET" });
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
next();
|
114
|
+
} catch (err) {
|
115
|
+
res.status(500).send({ message: err.message });
|
116
|
+
}
|
117
|
+
};
|
118
|
+
return {
|
119
|
+
checkUserExist
|
120
|
+
};
|
121
|
+
};
|
122
|
+
var verifyUser = middlewareFactory$2;
|
123
|
+
const { ObjectId } = require$$0$1;
|
124
|
+
const middlewareFactory$1 = (db) => {
|
125
|
+
const User = db.user;
|
126
|
+
const Invite = db.invite;
|
127
|
+
const Membership = db.membership;
|
128
|
+
const checkInviteExist = async (req, res, next) => {
|
129
|
+
for (let invite of req.body) {
|
130
|
+
let query;
|
131
|
+
if (invite.contact.includes("@")) {
|
132
|
+
query = { invitedEmail: invite.contact };
|
133
|
+
} else {
|
134
|
+
query = { invitedPhone: invite.contact };
|
135
|
+
}
|
136
|
+
query.organization = req.params._id;
|
137
|
+
const userInvite = await Invite.findOne(query).exec();
|
138
|
+
if (userInvite) {
|
139
|
+
console.log(userInvite);
|
140
|
+
res.status(400).send({ message: "Инвайт c таким email или телефоном уже создан!" });
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
next();
|
145
|
+
};
|
146
|
+
const checkUsersExist = async (req, res, next) => {
|
147
|
+
for (let invite of req.body) {
|
148
|
+
let query;
|
149
|
+
if (invite.contact.includes("@")) {
|
150
|
+
query = { email: invite.contact };
|
151
|
+
} else {
|
152
|
+
query = { phone: invite.contact };
|
153
|
+
}
|
154
|
+
const user = await User.findOne(query).exec();
|
155
|
+
console.log(req.params);
|
156
|
+
if (user) {
|
157
|
+
const membership = await Membership.findOne({ user: new ObjectId(user._id), organization: req.params._id }).exec();
|
158
|
+
if (membership) {
|
159
|
+
console.log(membership);
|
160
|
+
res.status(400).send({ message: "Пользователь с таким email или телефоном уже добавлен в организацию!" });
|
161
|
+
return;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
next();
|
166
|
+
};
|
167
|
+
return {
|
168
|
+
checkInviteExist,
|
169
|
+
checkUsersExist
|
170
|
+
};
|
171
|
+
};
|
172
|
+
var verifyInvites = middlewareFactory$1;
|
173
|
+
const middlewareFactory = (db) => {
|
174
|
+
const Category = db.category;
|
175
|
+
const checkCategoryExistOrNot = async (req, res, next) => {
|
176
|
+
try {
|
177
|
+
const category = await Category.findOne({ url: req.body.url });
|
178
|
+
if (category) {
|
179
|
+
res.status(400).send({ message: "Failed! Category with this URL is already in use!" });
|
180
|
+
return;
|
181
|
+
}
|
182
|
+
next();
|
183
|
+
} catch (err) {
|
184
|
+
res.status(500).send({ message: err });
|
185
|
+
}
|
186
|
+
};
|
187
|
+
return {
|
188
|
+
checkCategoryExistOrNot
|
189
|
+
};
|
190
|
+
};
|
191
|
+
var verifyCategory = middlewareFactory;
|
192
|
+
const middlewareIndexFactory = (db) => {
|
193
|
+
const authJwt$1 = authJwt(db);
|
194
|
+
const verifySignUp$1 = verifySignUp(db);
|
195
|
+
const verifyUser$1 = verifyUser(db);
|
196
|
+
const verifyInvites$1 = verifyInvites(db);
|
197
|
+
const verifyCategory$1 = verifyCategory(db);
|
198
|
+
return {
|
199
|
+
authJwt: authJwt$1,
|
200
|
+
verifySignUp: verifySignUp$1,
|
201
|
+
verifyUser: verifyUser$1,
|
202
|
+
verifyInvites: verifyInvites$1,
|
203
|
+
verifyCategory: verifyCategory$1
|
204
|
+
};
|
205
|
+
};
|
206
|
+
var server = middlewareIndexFactory;
|
207
|
+
export {
|
208
|
+
verifyInvites as a,
|
209
|
+
authJwt as b,
|
210
|
+
verifySignUp as c,
|
211
|
+
verifyCategory as d,
|
212
|
+
server as s,
|
213
|
+
verifyUser as v
|
214
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-83b1d755.mjs";
|
2
|
-
import { v as verifyUser$1, a as verifyInvites$1, b as authJwt$1, c as verifySignUp$1, d as verifyCategory$1, s as server } from "./index-
|
2
|
+
import { v as verifyUser$1, a as verifyInvites$1, b as authJwt$1, c as verifySignUp$1, d as verifyCategory$1, s as server } from "./index-d5066b82.mjs";
|
3
3
|
import "jsonwebtoken";
|
4
4
|
import "mongodb";
|
5
5
|
const verifyUser = verifyUser$1;
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="";
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),a=require("../FieldPhone/click-outside.cjs");require("./Dropdown.vue2.cjs");const u=require("../../../../_virtual/_plugin-vue_export-helper.cjs"),s={__name:"Dropdown",props:{label:{type:String,default:"Open"},align:{type:String,default:"left"}},setup(i){let n=a.default;const t=e.ref(!1);function r(){t.value=!1}return(o,l)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",{class:"dropdown pos-relative",onClick:l[0]||(l[0]=e.withModifiers(c=>t.value=!t.value,["stop"]))},[e.createTextVNode(e.toDisplayString(i.label)+" ",1),e.createVNode(e.Transition,{name:"TransitionTranslateY",mode:"out-in"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{style:e.normalizeStyle({left:i.align==="left"?"0":"auto",right:i.align==="right"?"0":"auto"}),class:"dropdown-content w-15r radius-big"},[e.renderSlot(o.$slots,"default",{},void 0,!0)],4),[[e.vShow,t.value]])]),_:3})])),[[e.unref(n),r]])}},d=u.default(s,[["__scopeId","data-v-2f59adb5"]]);exports.default=d;
|
@@ -1,4 +1,51 @@
|
|
1
|
-
|
1
|
+
import { ref as a, withDirectives as i, openBlock as d, createElementBlock as s, withModifiers as u, createTextVNode as c, toDisplayString as f, createVNode as p, Transition as m, withCtx as v, createElementVNode as g, normalizeStyle as w, renderSlot as k, vShow as S, unref as h } from "vue";
|
2
|
+
import y from "../FieldPhone/click-outside.js";
|
3
|
+
import "./Dropdown.vue2.js";
|
4
|
+
import O from "../../../../_virtual/_plugin-vue_export-helper.js";
|
5
|
+
const b = {
|
6
|
+
__name: "Dropdown",
|
7
|
+
props: {
|
8
|
+
label: {
|
9
|
+
type: String,
|
10
|
+
default: "Open"
|
11
|
+
},
|
12
|
+
align: {
|
13
|
+
type: String,
|
14
|
+
default: "left"
|
15
|
+
}
|
16
|
+
},
|
17
|
+
setup(t) {
|
18
|
+
let l = y;
|
19
|
+
const e = a(!1);
|
20
|
+
function n() {
|
21
|
+
e.value = !1;
|
22
|
+
}
|
23
|
+
return (r, o) => i((d(), s("div", {
|
24
|
+
class: "dropdown pos-relative",
|
25
|
+
onClick: o[0] || (o[0] = u((x) => e.value = !e.value, ["stop"]))
|
26
|
+
}, [
|
27
|
+
c(f(t.label) + " ", 1),
|
28
|
+
p(m, {
|
29
|
+
name: "TransitionTranslateY",
|
30
|
+
mode: "out-in"
|
31
|
+
}, {
|
32
|
+
default: v(() => [
|
33
|
+
i(g("div", {
|
34
|
+
style: w({ left: t.align === "left" ? "0" : "auto", right: t.align === "right" ? "0" : "auto" }),
|
35
|
+
class: "dropdown-content w-15r radius-big"
|
36
|
+
}, [
|
37
|
+
k(r.$slots, "default", {}, void 0, !0)
|
38
|
+
], 4), [
|
39
|
+
[S, e.value]
|
40
|
+
])
|
41
|
+
]),
|
42
|
+
_: 3
|
43
|
+
})
|
44
|
+
])), [
|
45
|
+
[h(l), n]
|
46
|
+
]);
|
47
|
+
}
|
48
|
+
}, N = /* @__PURE__ */ O(b, [["__scopeId", "data-v-2f59adb5"]]);
|
2
49
|
export {
|
3
|
-
|
50
|
+
N as default
|
4
51
|
};
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="";exports.default=e;
|