@ozdao/prometheus-framework 0.1.94 → 0.1.95

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. package/dist/auth.server.js +1 -1
  2. package/dist/auth.server.mjs +1 -1
  3. package/dist/community.server.js +1 -1
  4. package/dist/community.server.mjs +1 -1
  5. package/dist/events.server.js +1 -1
  6. package/dist/events.server.mjs +1 -1
  7. package/dist/files.server.js +1 -1
  8. package/dist/files.server.mjs +1 -1
  9. package/dist/gallery.server.js +1 -1
  10. package/dist/gallery.server.mjs +1 -1
  11. package/dist/index-96ec80f2.mjs +217 -0
  12. package/dist/index-fd6fdd90.js +216 -0
  13. package/dist/middlewares.server.js +1 -1
  14. package/dist/middlewares.server.mjs +1 -1
  15. package/dist/prometheus-framework/src/components/Button/Button.vue.cjs +1 -1
  16. package/dist/prometheus-framework/src/components/Button/Button.vue.js +224 -2
  17. package/dist/prometheus-framework/src/components/Button/Button.vue2.cjs +1 -1
  18. package/dist/prometheus-framework/src/components/Button/Button.vue2.js +2 -224
  19. package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +1 -1
  20. package/dist/prometheus-framework/src/components/Field/Field.vue.js +76 -2
  21. package/dist/prometheus-framework/src/components/Field/Field.vue2.cjs +1 -1
  22. package/dist/prometheus-framework/src/components/Field/Field.vue2.js +2 -76
  23. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.cjs +1 -1
  24. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.js +1 -1
  25. package/dist/prometheus-framework/src/components/LocationMarker/LocationMarker.vue.cjs +1 -1
  26. package/dist/prometheus-framework/src/components/LocationMarker/LocationMarker.vue.js +1 -1
  27. package/dist/prometheus-framework/src/components/Select/Select.vue.cjs +1 -1
  28. package/dist/prometheus-framework/src/components/Select/Select.vue.js +2 -78
  29. package/dist/prometheus-framework/src/components/Select/Select.vue2.cjs +1 -1
  30. package/dist/prometheus-framework/src/components/Select/Select.vue2.js +78 -2
  31. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
  32. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +2 -2
  33. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.cjs +1 -1
  34. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.js +1 -1
  35. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
  36. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +2 -2
  37. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  38. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +2 -2
  39. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
  40. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +2 -2
  41. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
  42. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +2 -2
  43. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
  44. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +2 -2
  45. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  46. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
  47. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.cjs +1 -1
  48. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.js +1 -1
  49. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
  50. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +4 -4
  51. package/dist/prometheus-framework/src/modules/community/store/blogposts.cjs +1 -1
  52. package/dist/prometheus-framework/src/modules/community/store/blogposts.js +1 -1
  53. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.cjs +1 -1
  54. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
  55. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.cjs +1 -4
  56. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.js +2 -62
  57. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.cjs +4 -1
  58. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.js +62 -2
  59. package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.cjs +1 -1
  60. package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.js +1 -1
  61. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.cjs +1 -1
  62. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
  63. package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.cjs +1 -1
  64. package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.js +1 -1
  65. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
  66. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +3 -3
  67. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.cjs +1 -1
  68. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.js +2 -2
  69. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  70. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +3 -3
  71. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.cjs +1 -1
  72. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.js +3 -3
  73. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  74. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +1 -1
  75. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  76. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +3 -3
  77. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.cjs +1 -1
  78. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.js +11 -2
  79. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.cjs +1 -1
  80. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.js +2 -11
  81. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.cjs +1 -1
  82. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.js +2 -2
  83. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.cjs +1 -1
  84. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
  85. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  86. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +3 -3
  87. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  88. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +4 -4
  89. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  90. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
  91. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
  92. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +2 -2
  93. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  94. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +3 -3
  95. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  96. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +3 -3
  97. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  98. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +2 -2
  99. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  100. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +3 -3
  101. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  102. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +2 -2
  103. package/dist/reports.server.js +1 -1
  104. package/dist/reports.server.mjs +1 -1
  105. package/dist/style.css +1 -1
  106. package/package.json +1 -1
  107. package/src/modules/community/components/pages/CreateBlogPost.vue +3 -2
  108. package/src/modules/community/store/blogposts.js +1 -0
  109. package/src/modules/middlewares/server/authJwt.js +15 -8
@@ -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-21dfdbd9.js");
10
+ const index = require("./index-fd6fdd90.js");
11
11
  require("dotenv");
12
12
  require("nodemailer");
13
13
  require("axios");
@@ -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-fa8d5df4.mjs";
9
+ import { s as server } from "./index-96ec80f2.mjs";
10
10
  import "dotenv";
11
11
  import "nodemailer";
12
12
  import "axios";
@@ -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-21dfdbd9.js");
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-fa8d5df4.mjs";
6
+ import { s as server$1 } from "./index-96ec80f2.mjs";
7
7
  import "jsonwebtoken";
8
8
  import "mongodb";
9
9
  function getPeriodConditions(period) {
@@ -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-21dfdbd9.js");
6
+ const index = require("./index-fd6fdd90.js");
7
7
  require("jsonwebtoken");
8
8
  require("mongodb");
9
9
  const ObjectId = require$$0.Types.ObjectId;
@@ -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-fa8d5df4.mjs";
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;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const _commonjsHelpers = require("./_commonjsHelpers-3b53548e.js");
3
- const index = require("./index-21dfdbd9.js");
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");
@@ -1,5 +1,5 @@
1
1
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-83b1d755.mjs";
2
- import { s as server$1 } from "./index-fa8d5df4.mjs";
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";
@@ -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-21dfdbd9.js");
4
+ const index = require("./index-fd6fdd90.js");
5
5
  require("jsonwebtoken");
6
6
  require("mongodb");
7
7
  const path = require$$2;
@@ -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-fa8d5df4.mjs";
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,6 +1,6 @@
1
1
  "use strict";
2
2
  const _commonjsHelpers = require("./_commonjsHelpers-3b53548e.js");
3
- const index = require("./index-21dfdbd9.js");
3
+ const index = require("./index-fd6fdd90.js");
4
4
  require("jsonwebtoken");
5
5
  require("mongodb");
6
6
  const verifyUser = index.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-fa8d5df4.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-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="";exports.default=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");require("./Button.vue2.cjs");const u=["onClick","disabled"],d={key:0},m={key:0,class:"loading"},h=e.createElementVNode("svg",{class:"i-regular",width:"135",height:"140",viewBox:"0 0 135 140",xmlns:"http://www.w3.org/2000/svg",fill:"#fff"},[e.createElementVNode("rect",{y:"10",width:"15",height:"120",rx:"6"},[e.createElementVNode("animate",{attributeName:"height",begin:"0.5s",dur:"1s",values:"120;110;100;90;80;70;60;50;40;140;120",calcMode:"linear",repeatCount:"indefinite"}),e.createTextVNode(),e.createElementVNode("animate",{attributeName:"y",begin:"0.5s",dur:"1s",values:"10;15;20;25;30;35;40;45;50;0;10",calcMode:"linear",repeatCount:"indefinite"})]),e.createElementVNode("rect",{x:"30",y:"10",width:"15",height:"120",rx:"6"},[e.createElementVNode("animate",{attributeName:"height",begin:"0.25s",dur:"1s",values:"120;110;100;90;80;70;60;50;40;140;120",calcMode:"linear",repeatCount:"indefinite"}),e.createTextVNode(),e.createElementVNode("animate",{attributeName:"y",begin:"0.25s",dur:"1s",values:"10;15;20;25;30;35;40;45;50;0;10",calcMode:"linear",repeatCount:"indefinite"})]),e.createElementVNode("rect",{x:"60",width:"15",height:"140",rx:"6"},[e.createElementVNode("animate",{attributeName:"height",begin:"0s",dur:"1s",values:"120;110;100;90;80;70;60;50;40;140;120",calcMode:"linear",repeatCount:"indefinite"}),e.createTextVNode(),e.createElementVNode("animate",{attributeName:"y",begin:"0s",dur:"1s",values:"10;15;20;25;30;35;40;45;50;0;10",calcMode:"linear",repeatCount:"indefinite"})]),e.createElementVNode("rect",{x:"90",y:"10",width:"15",height:"120",rx:"6"},[e.createElementVNode("animate",{attributeName:"height",begin:"0.25s",dur:"1s",values:"120;110;100;90;80;70;60;50;40;140;120",calcMode:"linear",repeatCount:"indefinite"}),e.createTextVNode(),e.createElementVNode("animate",{attributeName:"y",begin:"0.25s",dur:"1s",values:"10;15;20;25;30;35;40;45;50;0;10",calcMode:"linear",repeatCount:"indefinite"})]),e.createElementVNode("rect",{x:"120",y:"10",width:"15",height:"120",rx:"6"},[e.createElementVNode("animate",{attributeName:"height",begin:"0.5s",dur:"1s",values:"120;110;100;90;80;70;60;50;40;140;120",calcMode:"linear",repeatCount:"indefinite"}),e.createTextVNode(),e.createElementVNode("animate",{attributeName:"y",begin:"0.5s",dur:"1s",values:"10;15;20;25;30;35;40;45;50;0;10",calcMode:"linear",repeatCount:"indefinite"})])],-1),b=[h],f={key:0,class:"loading t-white"},g={key:0,class:"error"},v={__name:"Button",props:{submit:{type:Function,default:async()=>{console.log("Button click.")}},callback:{type:Function,default:async()=>{console.log("Button callback.")}},callbackDelay:{type:Number,default:750},showSucces:{type:Boolean,default:!0},validation:{type:Boolean,default:!1}},setup(r){const n=r,t=e.ref(null),a=e.ref(null),l=e.ref(!1),o=e.ref(!1);async function s(){t.value.style["pointer-events"]="none",a.value=null,l.value=!0;const i=()=>{t.value&&(t.value.classList.replace("bg-light-main","bg-main"),t.value.style.pointerEvents="auto",l.value=!1,o.value=!1,a.value=null)};try{await n.submit(),t.value.classList.replace("bg-main","bg-light-main"),l.value=!1,n.showSucces?(o.value=!0,setTimeout(i,500)):i(),n.callback&&setTimeout(()=>n.callback(),n.callbackDelay)}catch{t.value.classList.replace("bg-main","bg-fourth-nano"),a.value="❌",setTimeout(()=>{i(),t.value.classList.replace("bg-fourth-nano","bg-main")},1330)}}return(i,c)=>(e.openBlock(),e.createElementBlock("button",{onClick:e.withModifiers(s,["stop"]),disabled:r.validation,ref_key:"button",ref:t,class:"w-100 bg-main button"},[e.createVNode(e.Transition,{name:"TransitionTranslateY-small"},{default:e.withCtx(()=>[!l.value&&!a.value&&!o.value?(e.openBlock(),e.createElementBlock("span",d,[e.renderSlot(i.$slots,"default")])):e.createCommentVNode("",!0)]),_:3}),e.createVNode(e.Transition,{name:"TransitionTranslateY-small"},{default:e.withCtx(()=>[l.value&&!a.value?(e.openBlock(),e.createElementBlock("span",m,b)):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.Transition,{name:"TransitionTranslateY-small"},{default:e.withCtx(()=>[o.value&&r.showSucces?(e.openBlock(),e.createElementBlock("span",f,"✔")):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.Transition,{name:"TransitionTranslateY-small"},{default:e.withCtx(()=>[a.value?(e.openBlock(),e.createElementBlock("span",g,e.toDisplayString(a.value),1)):e.createCommentVNode("",!0)]),_:1})],8,u))}};exports.default=v;