shuttlepro-shared 1.1.4 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,12 +3,10 @@ const { getBodyFromDecodeToken, getModule } = require("../../utils");
3
3
 
4
4
  exports.checkPermission = async (req, res, next, values) => {
5
5
  try {
6
- console.log(req.headers, "headers");
7
6
  const token =
8
7
  req.headers && req.headers.authorization
9
8
  ? req.headers.authorization
10
9
  : null;
11
- console.log(token, "token");
12
10
  if (token) {
13
11
  const workspaceId =
14
12
  req.query?.workspaceId ||
@@ -21,7 +19,8 @@ exports.checkPermission = async (req, res, next, values) => {
21
19
  message: GenericMessages.WORKSPACE_NOT_FOUND,
22
20
  });
23
21
  }
24
- const body = getBodyFromDecodeToken(token);
22
+ const accessToken = token.split(" ")[1];
23
+ const body = getBodyFromDecodeToken(accessToken);
25
24
  if (body) {
26
25
  const { module, action } = values;
27
26
  const moduleObj = getModule(body, module);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/utils/index.js CHANGED
@@ -15,11 +15,13 @@ exports.getBodyFromDecodeToken = (token) => {
15
15
  };
16
16
 
17
17
  exports.getModule = (obj, module) => {
18
+ console.log(obj, "obj");
19
+ console.log(obj.permissions, "obj.permissions");
18
20
  return (
19
21
  (obj &&
20
22
  obj.permissions &&
21
23
  obj.permissions.length > 0 &&
22
- obj?.permissions[module]) ||
24
+ obj.permissions[module]) ||
23
25
  null
24
26
  );
25
27
  };