propro-utils 1.3.42 → 1.3.44

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.3.42",
3
+ "version": "1.3.44",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -41,7 +41,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
41
41
  const redirectUrl = `${authClientUrl}?response_type=code&appName=${appName}&client_id=${clientId}&redirect_uri=${encodeURIComponent(
42
42
  redirectUri
43
43
  )}`;
44
- res.status(200).json({redirectUrl});
44
+ return res.status(200).json({redirectUrl});
45
45
  }
46
46
 
47
47
  if (req.path === "/api/refreshToken") {
@@ -53,10 +53,10 @@ function proproAuthMiddleware(options = {}, userSchema) {
53
53
  const redirectUrl = `${authClientUrl}?response_type=code&appName=${appName}&client_id=${clientId}&redirect_uri=${encodeURIComponent(
54
54
  redirectUri
55
55
  )}`;
56
- res.status(401).json({redirectUrl, error: "No refresh token provided"});
56
+ return res.status(401).json({redirectUrl, error: "No refresh token provided"});
57
57
  }
58
58
 
59
- const {accountData, access, refresh} = await post(`${authUrl}/api/v1/auth/refreshTokens`, {
59
+ const response = await post(`${authUrl}/api/v1/auth/refreshTokens`, {
60
60
  refreshToken
61
61
  }, {
62
62
  params: {
@@ -64,10 +64,13 @@ function proproAuthMiddleware(options = {}, userSchema) {
64
64
  }
65
65
  });
66
66
 
67
- console.log("accountData", accountData);
68
- console.log("access", access);
69
- console.log("refresh", refresh);
70
67
 
68
+ const {account, access, refresh} = response.data;
69
+
70
+
71
+ if (!account || !access || !refresh) {
72
+ return res.status(401).json({error: "Invalid or expired refresh token"});
73
+ }
71
74
 
72
75
  const currentDateTime = new Date();
73
76