@ozdao/prometheus-framework 0.1.93 → 0.1.95
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-96ec80f2.mjs +217 -0
- package/dist/index-fd6fdd90.js +216 -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 +2 -49
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue2.js +49 -2
- package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Field/Field.vue.js +76 -2
- package/dist/prometheus-framework/src/components/Field/Field.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Field/Field.vue2.js +2 -76
- 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/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/layouts/Auth.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +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/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/store/blogposts.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/store/blogposts.js +19 -21
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.cjs +1 -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 +2 -2
- package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +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/legal/components/pages/Legal.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +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 +2 -2
- 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 +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/community/components/pages/CreateBlogPost.vue +3 -2
- package/src/modules/community/store/blogposts.js +1 -2
- package/src/modules/middlewares/server/authJwt.js +15 -8
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-9659b3c4.js");
|
10
|
-
const index = require("./index-
|
10
|
+
const index = require("./index-fd6fdd90.js");
|
11
11
|
require("dotenv");
|
12
12
|
require("nodemailer");
|
13
13
|
require("axios");
|
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-76895d59.mjs";
|
9
|
-
import { s as server } from "./index-
|
9
|
+
import { s as server } from "./index-96ec80f2.mjs";
|
10
10
|
import "dotenv";
|
11
11
|
import "nodemailer";
|
12
12
|
import "axios";
|
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-fd6fdd90.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-96ec80f2.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-fd6fdd90.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-96ec80f2.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-fd6fdd90.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-96ec80f2.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-fd6fdd90.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-96ec80f2.mjs";
|
4
4
|
import "jsonwebtoken";
|
5
5
|
import "mongodb";
|
6
6
|
const path = require$$2;
|
@@ -0,0 +1,217 @@
|
|
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
|
+
if (req.cookies.user) {
|
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
|
+
} else {
|
20
|
+
console.log("unsuccess");
|
21
|
+
}
|
22
|
+
next();
|
23
|
+
} catch (err) {
|
24
|
+
console.log(err);
|
25
|
+
return res.status(401).send({ message: "Unauthorized!" });
|
26
|
+
}
|
27
|
+
};
|
28
|
+
const checkRole = (roleToCheck) => async (req, res, next) => {
|
29
|
+
try {
|
30
|
+
const user = await User.findById(req.userId).exec();
|
31
|
+
if (!user) {
|
32
|
+
return res.status(404).send({ message: "User Not found." });
|
33
|
+
}
|
34
|
+
const roles = await Role.find({ _id: { $in: user.roles } }).exec();
|
35
|
+
for (let role of roles) {
|
36
|
+
if (role.name === roleToCheck) {
|
37
|
+
next();
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
res.status(403).send({ message: `Require ${roleToCheck} Role!` });
|
42
|
+
} catch (err) {
|
43
|
+
res.status(500).send({ message: err.message });
|
44
|
+
}
|
45
|
+
};
|
46
|
+
const isAdmin = checkRole("admin");
|
47
|
+
const isModerator = checkRole("moderator");
|
48
|
+
return {
|
49
|
+
verifyToken,
|
50
|
+
isAdmin,
|
51
|
+
isModerator
|
52
|
+
};
|
53
|
+
};
|
54
|
+
var authJwt = middlewareFactory$4;
|
55
|
+
const middlewareFactory$3 = (db) => {
|
56
|
+
const User = db.user;
|
57
|
+
db.role;
|
58
|
+
const checkDuplicateUsernameOrEmail = async (req, res, next) => {
|
59
|
+
const { type, email, phone } = req.body;
|
60
|
+
let query;
|
61
|
+
if (type === "phone" && phone) {
|
62
|
+
query = { phone };
|
63
|
+
}
|
64
|
+
if (type === "email" && email) {
|
65
|
+
query = { email };
|
66
|
+
}
|
67
|
+
try {
|
68
|
+
const user = await User.findOne(query).exec();
|
69
|
+
if (user) {
|
70
|
+
res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
next();
|
74
|
+
} catch (err) {
|
75
|
+
console.log(err);
|
76
|
+
res.status(500).send({ message: err.message });
|
77
|
+
}
|
78
|
+
};
|
79
|
+
const checkRolesExisted = (req, res, next) => {
|
80
|
+
if (req.body.roles) {
|
81
|
+
for (let i = 0; i < req.body.roles.length; i++) {
|
82
|
+
if (!ROLES.includes(req.body.roles[i])) {
|
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
|
+
res.status(400).send({ errorCode: "USER_NOT_REGISTERED_YET" });
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
next();
|
117
|
+
} catch (err) {
|
118
|
+
res.status(500).send({ message: err.message });
|
119
|
+
}
|
120
|
+
};
|
121
|
+
return {
|
122
|
+
checkUserExist
|
123
|
+
};
|
124
|
+
};
|
125
|
+
var verifyUser = middlewareFactory$2;
|
126
|
+
const { ObjectId } = require$$0$1;
|
127
|
+
const middlewareFactory$1 = (db) => {
|
128
|
+
const User = db.user;
|
129
|
+
const Invite = db.invite;
|
130
|
+
const Membership = db.membership;
|
131
|
+
const checkInviteExist = async (req, res, next) => {
|
132
|
+
for (let invite of req.body) {
|
133
|
+
let query;
|
134
|
+
if (invite.contact.includes("@")) {
|
135
|
+
query = { invitedEmail: invite.contact };
|
136
|
+
} else {
|
137
|
+
query = { invitedPhone: invite.contact };
|
138
|
+
}
|
139
|
+
query.organization = req.params._id;
|
140
|
+
const userInvite = await Invite.findOne(query).exec();
|
141
|
+
if (userInvite) {
|
142
|
+
console.log(userInvite);
|
143
|
+
res.status(400).send({ message: "Инвайт c таким email или телефоном уже создан!" });
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
next();
|
148
|
+
};
|
149
|
+
const checkUsersExist = async (req, res, next) => {
|
150
|
+
for (let invite of req.body) {
|
151
|
+
let query;
|
152
|
+
if (invite.contact.includes("@")) {
|
153
|
+
query = { email: invite.contact };
|
154
|
+
} else {
|
155
|
+
query = { phone: invite.contact };
|
156
|
+
}
|
157
|
+
const user = await User.findOne(query).exec();
|
158
|
+
console.log(req.params);
|
159
|
+
if (user) {
|
160
|
+
const membership = await Membership.findOne({ user: new ObjectId(user._id), organization: req.params._id }).exec();
|
161
|
+
if (membership) {
|
162
|
+
console.log(membership);
|
163
|
+
res.status(400).send({ message: "Пользователь с таким email или телефоном уже добавлен в организацию!" });
|
164
|
+
return;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
}
|
168
|
+
next();
|
169
|
+
};
|
170
|
+
return {
|
171
|
+
checkInviteExist,
|
172
|
+
checkUsersExist
|
173
|
+
};
|
174
|
+
};
|
175
|
+
var verifyInvites = middlewareFactory$1;
|
176
|
+
const middlewareFactory = (db) => {
|
177
|
+
const Category = db.category;
|
178
|
+
const checkCategoryExistOrNot = async (req, res, next) => {
|
179
|
+
try {
|
180
|
+
const category = await Category.findOne({ url: req.body.url });
|
181
|
+
if (category) {
|
182
|
+
res.status(400).send({ message: "Failed! Category with this URL is already in use!" });
|
183
|
+
return;
|
184
|
+
}
|
185
|
+
next();
|
186
|
+
} catch (err) {
|
187
|
+
res.status(500).send({ message: err });
|
188
|
+
}
|
189
|
+
};
|
190
|
+
return {
|
191
|
+
checkCategoryExistOrNot
|
192
|
+
};
|
193
|
+
};
|
194
|
+
var verifyCategory = middlewareFactory;
|
195
|
+
const middlewareIndexFactory = (db) => {
|
196
|
+
const authJwt$1 = authJwt(db);
|
197
|
+
const verifySignUp$1 = verifySignUp(db);
|
198
|
+
const verifyUser$1 = verifyUser(db);
|
199
|
+
const verifyInvites$1 = verifyInvites(db);
|
200
|
+
const verifyCategory$1 = verifyCategory(db);
|
201
|
+
return {
|
202
|
+
authJwt: authJwt$1,
|
203
|
+
verifySignUp: verifySignUp$1,
|
204
|
+
verifyUser: verifyUser$1,
|
205
|
+
verifyInvites: verifyInvites$1,
|
206
|
+
verifyCategory: verifyCategory$1
|
207
|
+
};
|
208
|
+
};
|
209
|
+
var server = middlewareIndexFactory;
|
210
|
+
export {
|
211
|
+
verifyInvites as a,
|
212
|
+
authJwt as b,
|
213
|
+
verifySignUp as c,
|
214
|
+
verifyCategory as d,
|
215
|
+
server as s,
|
216
|
+
verifyUser as v
|
217
|
+
};
|
@@ -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
|
+
if (req.cookies.user) {
|
12
|
+
let user = JSON.parse(req.cookies.user);
|
13
|
+
let token = req.headers["x-access-token"] || user.accessToken;
|
14
|
+
if (!token) {
|
15
|
+
return res.status(403).send({ message: "No token provided!" });
|
16
|
+
}
|
17
|
+
const decoded = jwt.verify(token, process.env.SECRET_KEY);
|
18
|
+
req.userId = decoded.id;
|
19
|
+
console.log("success");
|
20
|
+
} else {
|
21
|
+
console.log("unsuccess");
|
22
|
+
}
|
23
|
+
next();
|
24
|
+
} catch (err) {
|
25
|
+
console.log(err);
|
26
|
+
return res.status(401).send({ message: "Unauthorized!" });
|
27
|
+
}
|
28
|
+
};
|
29
|
+
const checkRole = (roleToCheck) => async (req, res, next) => {
|
30
|
+
try {
|
31
|
+
const user = await User.findById(req.userId).exec();
|
32
|
+
if (!user) {
|
33
|
+
return res.status(404).send({ message: "User Not found." });
|
34
|
+
}
|
35
|
+
const roles = await Role.find({ _id: { $in: user.roles } }).exec();
|
36
|
+
for (let role of roles) {
|
37
|
+
if (role.name === roleToCheck) {
|
38
|
+
next();
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
res.status(403).send({ message: `Require ${roleToCheck} Role!` });
|
43
|
+
} catch (err) {
|
44
|
+
res.status(500).send({ message: err.message });
|
45
|
+
}
|
46
|
+
};
|
47
|
+
const isAdmin = checkRole("admin");
|
48
|
+
const isModerator = checkRole("moderator");
|
49
|
+
return {
|
50
|
+
verifyToken,
|
51
|
+
isAdmin,
|
52
|
+
isModerator
|
53
|
+
};
|
54
|
+
};
|
55
|
+
var authJwt = middlewareFactory$4;
|
56
|
+
const middlewareFactory$3 = (db) => {
|
57
|
+
const User = db.user;
|
58
|
+
db.role;
|
59
|
+
const checkDuplicateUsernameOrEmail = async (req, res, next) => {
|
60
|
+
const { type, email, phone } = req.body;
|
61
|
+
let query;
|
62
|
+
if (type === "phone" && phone) {
|
63
|
+
query = { phone };
|
64
|
+
}
|
65
|
+
if (type === "email" && email) {
|
66
|
+
query = { email };
|
67
|
+
}
|
68
|
+
try {
|
69
|
+
const user = await User.findOne(query).exec();
|
70
|
+
if (user) {
|
71
|
+
res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
next();
|
75
|
+
} catch (err) {
|
76
|
+
console.log(err);
|
77
|
+
res.status(500).send({ message: err.message });
|
78
|
+
}
|
79
|
+
};
|
80
|
+
const checkRolesExisted = (req, res, next) => {
|
81
|
+
if (req.body.roles) {
|
82
|
+
for (let i = 0; i < req.body.roles.length; i++) {
|
83
|
+
if (!ROLES.includes(req.body.roles[i])) {
|
84
|
+
res.status(400).send({
|
85
|
+
message: `Failed! Role ${req.body.roles[i]} does not exist!`
|
86
|
+
});
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
next();
|
92
|
+
};
|
93
|
+
return {
|
94
|
+
checkDuplicateUsernameOrEmail,
|
95
|
+
checkRolesExisted
|
96
|
+
};
|
97
|
+
};
|
98
|
+
var verifySignUp = middlewareFactory$3;
|
99
|
+
const middlewareFactory$2 = (db) => {
|
100
|
+
const User = db.user;
|
101
|
+
db.role;
|
102
|
+
const checkUserExist = async (req, res, next) => {
|
103
|
+
const { type, email, phone } = 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
|
+
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;
|
@@ -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-96ec80f2.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="";exports.default=e;
|
@@ -1,51 +1,4 @@
|
|
1
|
-
|
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"]]);
|
1
|
+
const _ = "";
|
49
2
|
export {
|
50
|
-
|
3
|
+
_ as default
|
51
4
|
};
|
@@ -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.vue.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.vue.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="";exports.default=
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");require("./Field.vue2.cjs");const u=require("../../../../_virtual/_plugin-vue_export-helper.cjs"),r={key:0,class:"t-transp mn-r-small"},c={class:"w-100"},m=["type","value","placeholder","tabindex"],f=["value","placeholder","tabindex"],b={key:1,class:"t-transp mn-l-small"},v={key:0,class:"mn-t-thin mn-thin mn-b-thin invalid-feedback"},k={__name:"Field",props:{label:null,symbol:null,type:"text",placeholder:"Enter something here",field:null,validation:!1,disabled:!1,tabindex:-1},emits:["update:field","focus","blur"],setup(t,{emit:i}){const a=i,s=t,o=e.ref(s.field);return(d,l)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass([[d.$attrs.class,{"bg-fourth-nano":t.validation}],"flex-center flex-nowrap flex"])},[t.label?(e.openBlock(),e.createElementBlock("div",r,[e.createElementVNode("span",null,e.toDisplayString(t.label),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",c,[t.type!=="textarea"?(e.openBlock(),e.createElementBlock("input",{key:0,onInput:l[0]||(l[0]=n=>o.value=a("update:field",n.target.value)),onFocus:l[1]||(l[1]=n=>a("focus",n)),onBlur:l[2]||(l[2]=n=>a("blur",n)),type:t.type,class:"w-100",value:t.field,placeholder:t.placeholder,tabindex:t.tabindex},null,40,m)):(e.openBlock(),e.createElementBlock("textarea",{key:1,onInput:l[3]||(l[3]=n=>o.value=a("update:field",n.target.value)),onFocus:l[4]||(l[4]=n=>a("focus",n)),onBlur:l[5]||(l[5]=n=>a("blur",n)),class:"w-100",value:t.field,placeholder:t.placeholder,tabindex:t.tabindex},null,40,f))]),e.renderSlot(d.$slots,"default",{},void 0,!0),t.symbol?(e.openBlock(),e.createElementBlock("div",b,[e.createElementVNode("span",null,e.toDisplayString(t.symbol),1)])):e.createCommentVNode("",!0)],2),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[t.validation?(e.openBlock(),e.createElementBlock("div",v," * "+e.toDisplayString(t.validation.message),1)):e.createCommentVNode("",!0)]),_:1})],64))}},y=u.default(k,[["__scopeId","data-v-839e7ced"]]);exports.default=y;
|