@ozdao/prometheus-framework 0.2.137 → 0.2.139

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. package/dist/auth.server.js +29 -14
  2. package/dist/auth.server.mjs +29 -14
  3. package/dist/community.server.js +3 -3
  4. package/dist/community.server.mjs +3 -3
  5. package/dist/events.server.js +3 -3
  6. package/dist/events.server.mjs +3 -3
  7. package/dist/files.server.js +3 -3
  8. package/dist/files.server.mjs +3 -3
  9. package/dist/gallery.server.js +4 -4
  10. package/dist/gallery.server.mjs +4 -4
  11. package/dist/index-DNI4aUP2.js +259 -0
  12. package/dist/index-Tcyehi73.mjs +260 -0
  13. package/dist/main-DTHFR7H_.mjs +14510 -0
  14. package/dist/main-wXdocsbd.js +92 -0
  15. package/dist/main.css +1 -1
  16. package/dist/orders.server.js +9 -8
  17. package/dist/orders.server.mjs +9 -8
  18. package/dist/organizations.server.js +32 -17
  19. package/dist/organizations.server.mjs +32 -17
  20. package/dist/products.server.js +37 -5
  21. package/dist/products.server.mjs +37 -5
  22. package/dist/prometheus-framework/src/components/Block/Block.vue.cjs +1 -1
  23. package/dist/prometheus-framework/src/components/Block/Block.vue.js +1 -1
  24. package/dist/prometheus-framework/src/components/Completion/Completion.vue.cjs +1 -1
  25. package/dist/prometheus-framework/src/components/Completion/Completion.vue.js +19 -19
  26. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  27. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +1 -1
  28. package/dist/prometheus-framework/src/components/Map/Map.vue.cjs +1 -1
  29. package/dist/prometheus-framework/src/components/Map/Map.vue.js +3 -2
  30. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  31. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +32 -31
  32. package/dist/prometheus-framework/src/modules/auth/store/auth.cjs +1 -1
  33. package/dist/prometheus-framework/src/modules/auth/store/auth.js +50 -47
  34. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  35. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
  36. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
  37. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +1 -1
  38. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  39. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +2 -2
  40. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  41. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +1 -1
  42. package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.cjs +1 -1
  43. package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.js +1 -1
  44. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
  45. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +12 -12
  46. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
  47. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +2 -2
  48. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
  49. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +41 -38
  50. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  51. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +123 -114
  52. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  53. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +51 -52
  54. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
  55. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
  56. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
  57. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +16 -15
  58. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  59. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +120 -60
  60. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  61. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +1 -1
  62. package/dist/prometheus-framework/src/modules/organizations/store/invites.cjs +1 -1
  63. package/dist/prometheus-framework/src/modules/organizations/store/invites.js +25 -24
  64. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
  65. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.js +7 -7
  66. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
  67. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.js +3 -3
  68. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.cjs +1 -1
  69. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.js +65 -66
  70. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.cjs +1 -1
  71. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.js +81 -76
  72. package/dist/prometheus-framework/src/modules/spots/router/spots.cjs +1 -1
  73. package/dist/prometheus-framework/src/modules/spots/router/spots.js +1 -1
  74. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  75. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +2 -2
  76. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  77. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +78 -74
  78. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  79. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +2 -2
  80. package/dist/prometheus-framework.cjs.js +1 -1
  81. package/dist/prometheus-framework.es.js +1 -1
  82. package/dist/reports.server.js +0 -3
  83. package/dist/reports.server.mjs +0 -3
  84. package/dist/spots.server.js +3 -3
  85. package/dist/spots.server.mjs +3 -3
  86. package/dist/style.css +1 -1
  87. package/dist/wallet.server.js +5 -5
  88. package/dist/wallet.server.mjs +8 -8
  89. package/dist/web-Dh669DqQ.mjs +54 -0
  90. package/dist/web-Dt2RCU54.js +1 -0
  91. package/package.json +1 -1
  92. package/src/components/Completion/Completion.vue +29 -30
  93. package/src/components/Map/Map.vue +2 -2
  94. package/src/modules/auth/components/pages/Invite.vue +4 -2
  95. package/src/modules/auth/controllers/auth.controller.js +30 -12
  96. package/src/modules/auth/middlewares/authJwt.js +80 -0
  97. package/src/modules/{middlewares/server → auth/middlewares}/index.js +1 -3
  98. package/src/modules/{middlewares/server → auth/middlewares}/verifyAccesses.js +1 -1
  99. package/src/modules/auth/routes/auth.routes.js +2 -2
  100. package/src/modules/auth/routes/twofa.routes.js +1 -1
  101. package/src/modules/auth/store/auth.js +9 -0
  102. package/src/modules/chats/routes/chats.routes.js +1 -1
  103. package/src/modules/community/routes/blog.routes.js +2 -2
  104. package/src/modules/events/routes/events.routes.js +2 -2
  105. package/src/modules/files/routes/files.routes.js +2 -2
  106. package/src/modules/gallery/routes/gallery.routes.js +4 -5
  107. package/src/modules/globals/services/globals.crud.js +2 -2
  108. package/src/modules/marketplace/store/marketplace.js +1 -1
  109. package/src/modules/orders/components/pages/OrderCreateBackoffice.vue +2 -2
  110. package/src/modules/orders/components/sections/FormAddCustomer.vue +2 -2
  111. package/src/modules/orders/controllers/orders.controller.js +1 -0
  112. package/src/modules/orders/routes/applications.routes.js +2 -2
  113. package/src/modules/orders/routes/orders.routes.js +2 -2
  114. package/src/modules/organizations/components/blocks/CardOrganization.vue +9 -7
  115. package/src/modules/organizations/components/pages/Members.vue +26 -15
  116. package/src/modules/organizations/components/pages/Organization.vue +3 -3
  117. package/src/modules/organizations/components/sections/DetailsTab.vue +1 -1
  118. package/src/modules/organizations/components/sections/MembersAdd.vue +101 -43
  119. package/src/modules/organizations/controllers/invites.controller.js +18 -13
  120. package/src/modules/organizations/controllers/memberships.controller.js +18 -11
  121. package/src/modules/organizations/controllers/organizations.controller.js +3 -4
  122. package/src/modules/organizations/models/membership.model.js +2 -0
  123. package/src/modules/organizations/models/organization.model.js +4 -0
  124. package/src/modules/organizations/routes/invites.routes.js +2 -2
  125. package/src/modules/organizations/store/invites.js +2 -1
  126. package/src/modules/products/controllers/leftovers.controller.js +1 -1
  127. package/src/modules/products/middlewares/index.js +11 -0
  128. package/src/modules/products/routes/categories.routes.js +2 -2
  129. package/src/modules/reports/routes/reports.routes.js +2 -2
  130. package/src/modules/spots/components/blocks/CardSpot.vue +0 -1
  131. package/src/modules/spots/components/layouts/Spots.vue +2 -2
  132. package/src/modules/spots/components/pages/Map.vue +79 -78
  133. package/src/modules/spots/components/pages/SpotEdit.vue +8 -5
  134. package/src/modules/spots/controllers/spots.controller.js +1 -5
  135. package/src/modules/spots/router/spots.js +1 -1
  136. package/src/modules/users/components/pages/ProfileEdit.vue +37 -22
  137. package/src/modules/wallet/controllers/routes/payments.routes.js +2 -2
  138. package/src/modules/wallet/controllers/routes/rewards.routes.js +2 -2
  139. package/src/modules/middlewares/server/authJwt.js +0 -68
  140. /package/src/modules/{middlewares/server → auth/middlewares}/authSecret.js +0 -0
  141. /package/src/modules/{middlewares/server → auth/middlewares}/verifyInvites.js +0 -0
  142. /package/src/modules/{middlewares/server → auth/middlewares}/verifySignUp.js +0 -0
  143. /package/src/modules/{middlewares/server → auth/middlewares}/verifyUser.js +0 -0
  144. /package/src/modules/globals/services/{globals.cashe.js → globals.cache.js} +0 -0
  145. /package/src/modules/{middlewares/server → products/middlewares}/verifyCategory.js +0 -0
@@ -96,7 +96,8 @@
96
96
  <Address
97
97
  :apiKey="GOOGLE_MAPS_API_KEY"
98
98
  :address="spots.state.spot.address"
99
- :location="spots.state.spot.location"
99
+ :location="spots.state.spot.location"
100
+ :locale="$i18n.locale"
100
101
  label="Address"
101
102
  placeholder="Enter delivery address"
102
103
  class="
@@ -114,7 +115,8 @@
114
115
 
115
116
  :address="spots.state.spot.address"
116
117
  :location="spots.state.spot.location"
117
-
118
+ :locale="$i18n.locale"
119
+
118
120
  class="h-20r mn-b-small radius-bl-medium radius-br-medium o-hidden"
119
121
  @update:location="newLocation => {
120
122
  spots.state.spot.location = newLocation;
@@ -144,7 +146,7 @@
144
146
  </Block>
145
147
  </div>
146
148
 
147
- <Button :submit="onDelete" :callback="redirectToDash" class="w-100 bg-light">Delete Spot</Button>
149
+ <Button :submit="onDelete" :callback="redirectDash" class="w-100 bg-light">Delete Spot</Button>
148
150
  </div>
149
151
  </template>
150
152
 
@@ -211,7 +213,8 @@ async function onSubmit() {
211
213
  }
212
214
 
213
215
  function redirectTo() {
214
- router.replace({ name: "Spot", params: { _id: route.params._id, spot: spots.state.spot._id } });
216
+ // router.replace({ name: "Spot", params: { _id: route.params._id, spot: spots.state.spot._id } });
217
+ router.push({ name: "Organization", params: { _id: route.params._id }});
215
218
  }
216
219
 
217
220
  async function onDelete() {
@@ -222,7 +225,7 @@ async function onDelete() {
222
225
  }
223
226
 
224
227
  function redirectDash() {
225
- router.replace({ name: "Organization" });
228
+ router.push({ name: "Organization", params: { _id: route.params._id }});
226
229
  }
227
230
  </script>
228
231
 
@@ -3,8 +3,6 @@ const controllerFactory = (db) => {
3
3
 
4
4
  const readOne = (req, res) => {
5
5
  Spot.findOne({_id: req.params._id})
6
- .populate('members.user')
7
- .populate('subspots')
8
6
  .then(spot => {
9
7
  if (!spot) {
10
8
  return res.status(404).send({ message: "Отдел не найден" });
@@ -18,8 +16,6 @@ const controllerFactory = (db) => {
18
16
 
19
17
  const read = (req, res) => {
20
18
  Spot.find({ organization: req.params._id })
21
- .populate('members.user')
22
- .populate('subspots')
23
19
  .then(spots => {
24
20
  if (!spots) {
25
21
  return res.status(404).send({ message: "Spots not found" });
@@ -60,7 +56,7 @@ const controllerFactory = (db) => {
60
56
  };
61
57
 
62
58
  const deleteSpot = (req, res) => {
63
- Spot.findOneAndRemove({ _id: req.body._id, organization: req.params._id })
59
+ Spot.findOneAndDelete({ _id: req.body._id, organization: req.params._id })
64
60
  .then(spot => {
65
61
  if (!spot) {
66
62
  return res.status(404).send({ message: "Spot not found" });
@@ -50,7 +50,7 @@ const spots = {
50
50
  ],
51
51
  component: () => import(/* webpackChunkName: "spot" */ '@pf/src/modules/spots/components/pages/SpotEdit.vue'),
52
52
  }, {
53
- path: ':_id/spots/:deparment',
53
+ path: ':_id/spots/:spot',
54
54
  name: 'Spot',
55
55
  meta: {
56
56
  title: 'Точка',
@@ -1,17 +1,17 @@
1
1
  <template>
2
- <div class="pd-medium for-transition w-100">
2
+ <div v-if="show" class="pd-medium for-transition w-100">
3
3
 
4
4
  <ProfileCompletion
5
5
  v-if="route.params._id === auth.state.user._id"
6
- :user="auth.state.user._id"
7
- :target="user"
6
+ :user="auth.state.user._id"
7
+ :target="users.state.current"
8
8
  :cta="false"
9
9
  />
10
10
  <!-- -->
11
11
  <h3 class="mn-b-small">Username</h3>
12
12
 
13
13
  <Field
14
- v-model:field="user.username"
14
+ v-model:field="users.state.current.username"
15
15
  label="@"
16
16
  placeholder="Not specified"
17
17
  class="mn-b-thin w-100 bg-light pd-medium radius-small"
@@ -25,15 +25,15 @@
25
25
 
26
26
  <div class="mn-b-thin radius-small w-100 h-10r bg-light flex-center flex-column flex">
27
27
  <UploadImage
28
- v-model:photo="user.profile.photo"
29
- :uploadPath="'users/' + user._id + '/avatars'"
28
+ v-model:photo="users.state.current.profile.photo"
29
+ :uploadPath="'users/' + users.state.current._id + '/avatars'"
30
30
  class="h-4r w-4r aspect-1x1 o-hidden bg-white mn-b-thin radius-extra"
31
31
  />
32
32
  <h4>Upload userpic</h4>
33
33
  </div>
34
34
 
35
35
  <Field
36
- v-model:field="user.profile.name"
36
+ v-model:field="users.state.current.profile.name"
37
37
  label="Name"
38
38
  placeholder="Not specified"
39
39
  class="mn-b-thin bg-light pd-medium radius-small"
@@ -41,18 +41,17 @@
41
41
  />
42
42
 
43
43
  <Field
44
- v-model:field="user.profile.description"
44
+ v-model:field="users.state.current.profile.description"
45
45
  label="Description"
46
46
  placeholder="Not specified"
47
47
  class="mn-b-semi bg-light pd-medium radius-small"
48
- disabled="true"
49
48
  :validation="organizationName"
50
49
  />
51
50
 
52
51
  <!-- <p class="mn-b-thin">Select your birthday if you want to receive your birthday gift.</p>
53
52
 
54
53
  <Field
55
- v-model:field="user.birthday"
54
+ v-model:field="users.state.current.birthday"
56
55
  label="Birthday"
57
56
  type="date"
58
57
  placeholder="Not specified"
@@ -63,25 +62,25 @@
63
62
  <p class="mn-b-thin">Please provide only the username for social media profiles, without full links.</p>
64
63
 
65
64
  <Field
66
- v-model:field="user.socials.instagram"
65
+ v-model:field="users.state.current.socials.instagram"
67
66
  label="Instagram"
68
67
  placeholder=""
69
68
  class="mn-b-thin bg-light pd-medium radius-small"
70
69
  />
71
70
  <Field
72
- v-model:field="user.socials.twitter"
71
+ v-model:field="users.state.current.socials.twitter"
73
72
  label="Twitter"
74
73
  placeholder=""
75
74
  class="mn-b-thin bg-light pd-medium radius-small"
76
75
  />
77
76
  <Field
78
- v-model:field="user.socials.facebook"
77
+ v-model:field="users.state.current.socials.facebook"
79
78
  label="Facebook"
80
79
  placeholder=""
81
80
  class="mn-b-thin bg-light pd-medium radius-small"
82
81
  />
83
82
  <Field
84
- v-model:field="user.socials.telegram"
83
+ v-model:field="users.state.current.socials.telegram"
85
84
  label="Telegram"
86
85
  placeholder=""
87
86
  class="mn-b-semi bg-light pd-medium radius-small"
@@ -90,7 +89,7 @@
90
89
  <h3 class="mn-b-small">Account</h3>
91
90
 
92
91
  <Field
93
- v-model:field="user.phone"
92
+ v-model:field="users.state.current.phone"
94
93
  label="Phone"
95
94
  placeholder="Not specified"
96
95
  class="mn-b-thin bg-light pd-medium mn-b-thin radius-small"
@@ -99,17 +98,29 @@
99
98
  />
100
99
 
101
100
  <Field
102
- v-model:field="user.email"
101
+ v-model:field="users.state.current.email"
103
102
  label="Email"
104
103
  placeholder="Not specified"
105
- class="mn-b-semi bg-light pd-medium radius-small"
104
+ class="mn-b-semi bg-light pd-medium radius-small"
106
105
  :disabled="true"
107
106
  :validation="organizationName"
108
107
  />
109
108
 
110
- <Button :submit="onSubmit" :callback="redirectTo" class="mn-b-thin">Save</Button>
109
+ <Button
110
+ :submit="onSubmit"
111
+ :callback="redirectTo"
112
+ class="mn-b-thin bg-main w-100"
113
+ >
114
+ Save
115
+ </Button>
111
116
 
112
- <Button :submit="onSubmitDelete" :callback="a = () => {router.push({name: 'Sign In'})}" class="mn-b-thin bg-red t-white">Delete Account</Button>
117
+ <Button
118
+ :submit="onSubmitDelete"
119
+ :callback="a = () => {router.push({name: 'Sign In'})}"
120
+ class="mn-b-thin w-100 bg-red t-white"
121
+ >
122
+ Delete Account
123
+ </Button>
113
124
  </div>
114
125
  </template>
115
126
 
@@ -132,10 +143,14 @@
132
143
  // Accessing router
133
144
  const route = useRoute()
134
145
  const router = useRouter()
135
- // Async requests
136
- const user = ref(users.state.current);
146
+
147
+ const user = ref(null)
148
+ const show = ref(false)
149
+
150
+
137
151
  onMounted(async () => {
138
- await users.actions.read({ _id: route.params._id });
152
+ await users.actions.read({ _id: route.params._id, user: auth.state.user._id });
153
+ show.value = true
139
154
  })
140
155
  // Methods
141
156
  async function onSubmit() {
@@ -1,5 +1,5 @@
1
1
  // Middlewares
2
- const middlewareFactory = require('@pf/src/modules/middlewares/server');
2
+ const middlewareFactoryAuth = require('@pf/src/modules/auth/middlewares');
3
3
  // Factories
4
4
  const controllerFactory = require("../factories/payments.factory");
5
5
  const controllerFactoryTickets = require("@pf/src/modules/events/controllers/tickets.controller");
@@ -16,7 +16,7 @@ module.exports = function(app, db, origins, publicPath) {
16
16
  const controller = controllerFactory(db);
17
17
  const controllerTickets = controllerFactoryTickets(db, publicPath);
18
18
 
19
- const { verifySignUp, verifyUser } = middlewareFactory(db);
19
+ const { verifySignUp, verifyUser } = middlewareFactoryAuth(db);
20
20
 
21
21
  observer.subscribe('checkout.session.completed', async (paymentIntent) => {
22
22
  const event = await db.event.findOne({ _id: paymentIntent.metadata.product });
@@ -2,13 +2,13 @@
2
2
  const rewardsControllerFactory = require('../factories/rewards.factory');
3
3
 
4
4
  // Middlewares
5
- const middlewareFactory = require('@pf/src/modules/middlewares/server');
5
+ const middlewareFactoryAuth = require('@pf/src/modules/auth/middlewares');
6
6
 
7
7
  // Routes
8
8
  module.exports = (app, db, wss, wdmClient, origins) => {
9
9
  const controller = rewardsControllerFactory(db, wdmClient, wss);
10
10
 
11
- const { authJwt, authSecret } = middlewareFactory(db);
11
+ const { authJwt, authSecret } = middlewareFactoryAuth(db);
12
12
 
13
13
  app.use((req, res, next) => {
14
14
  const origin = req.headers.origin;
@@ -1,68 +0,0 @@
1
- const jwt = require("jsonwebtoken");
2
-
3
- const middlewareFactory = (db) => {
4
- const User = db.user;
5
- const Role = db.role;
6
-
7
- const verifyToken = async (req, res, next) => {
8
- try {
9
- if (!req.cookies.user) {
10
- // Вместо возврата ошибки, просто устанавливаем req.userId как null
11
- req.userId = null;
12
- return next();
13
- }
14
-
15
- let user = JSON.parse(req.cookies.user);
16
- let token = req.headers["x-access-token"] || user.accessToken;
17
-
18
- if (!token) {
19
- // Также устанавливаем req.userId как null
20
- req.userId = null;
21
- return next();
22
- }
23
-
24
- const decoded = jwt.verify(token, process.env.SECRET_KEY);
25
- req.userId = decoded._id;
26
-
27
- next();
28
- } catch (err) {
29
- console.log(err);
30
- req.userId = null;
31
- next();
32
- }
33
- };
34
-
35
- const checkRole = roleToCheck => async (req, res, next) => {
36
- try {
37
- const user = await User.findById(req.userId).exec();
38
-
39
- if (!user) {
40
- return res.status(404).send({ message: "User Not found." });
41
- }
42
-
43
- const roles = await Role.find({ _id: { $in: user.roles }}).exec();
44
-
45
- for (let role of roles) {
46
- if (role.name === roleToCheck) {
47
- next();
48
- return;
49
- }
50
- }
51
-
52
- res.status(403).send({ message: `Require ${roleToCheck} Role!` });
53
- } catch (err) {
54
- res.status(500).send({ message: err.message });
55
- }
56
- };
57
-
58
- const isAdmin = checkRole("admin");
59
- const isModerator = checkRole("moderator");
60
-
61
- return {
62
- verifyToken,
63
- isAdmin,
64
- isModerator
65
- };
66
- };
67
-
68
- module.exports = middlewareFactory;