propro-utils 1.4.8 → 1.4.10

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.4.8",
3
+ "version": "1.4.10",
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
  console.log('req.path', req.path);
42
42
  if (req.path === '/api/auth') {
43
43
  const redirectUrl = constructRedirectUrl(clientUrl, appName, clientId, redirectUri);
44
- res.status(200).json({redirectUrl});
44
+ return res.status(200).json({redirectUrl});
45
45
  }
46
46
 
47
47
  if (req.path === '/api/refreshToken') {
@@ -51,7 +51,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
51
51
  // const refreshToken = req.cookies['x-refresh-token'];
52
52
  if (!refreshToken) {
53
53
  const redirectUrl = constructRedirectUrl(clientUrl, appName, clientId, redirectUri);
54
- res
54
+ return res
55
55
  .status(401)
56
56
  .json({redirectUrl, error: 'No refresh token provided'});
57
57
  }
@@ -71,7 +71,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
71
71
  const {account, access, refresh} = response.data;
72
72
 
73
73
  if (!account || !access || !refresh) {
74
- res
74
+ return res
75
75
  .status(401)
76
76
  .json({error: 'Invalid or expired refresh token'});
77
77
  }
@@ -96,15 +96,18 @@ function proproAuthMiddleware(options = {}, userSchema) {
96
96
  maxAge: accessMaxAge,
97
97
  });
98
98
 
99
- res
99
+ return res
100
100
  .status(200)
101
101
  .json({message: 'Token refreshed successfully'});
102
102
  }
103
103
 
104
+ console.log('req.path', req.path);
105
+ console.log('req.query', req.query);
106
+ console.log('authUrl', authUrl);
104
107
  if (req.path === '/api/callback') {
105
108
  const code = req.query.code;
106
109
  if (!code) {
107
- res.status(400).send('No code received');
110
+ return res.status(400).send('No code received');
108
111
  }
109
112
 
110
113
  const {tokens, account, redirectUrl} = await exchangeToken(
@@ -144,7 +147,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
144
147
 
145
148
  const urlToRedirect = `http://${redirectUrl}/`;
146
149
 
147
- res.redirect(urlToRedirect);
150
+ return res.redirect(urlToRedirect);
148
151
  }
149
152
  } catch (error) {
150
153
  // console.error("Error in proproAuthMiddleware:", error);