propro-utils 1.3.26 → 1.3.27

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.
@@ -11,14 +11,15 @@ const authValidation = (redisClient, requiredPermissions = []) => {
11
11
  return res.status(403).json({ error: "Access token is required" });
12
12
  }
13
13
 
14
- const response = await getOrSetCache(redisClient, accessToken, async () => {
15
- return await axios.post(`${process.env.AUTH_URL}/api/v1/auth/validateToken`, {
14
+ const fetchPermission = async () => {
15
+ const response = await axios.post(`${process.env.AUTH_URL}/api/v1/auth/validateToken`, {
16
16
  accessToken: accessToken,
17
17
  requiredPermissions: requiredPermissions
18
18
  });
19
- });
19
+ return response.data;
20
+ }
20
21
 
21
- const { accountId, validPermissions } = response.data;
22
+ const { accountId, validPermissions } = await getOrSetCache(redisClient, accessToken, fetchPermission, 1800);
22
23
 
23
24
  if (!validPermissions) {
24
25
  return res.status(403).json({ error: "Invalid permissions" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.3.26",
3
+ "version": "1.3.27",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {