propro-utils 1.4.6 → 1.4.8

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.6",
3
+ "version": "1.4.8",
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
- return res.status(200).json({redirectUrl});
44
+ 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
- return res
54
+ 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
- return res
74
+ res
75
75
  .status(401)
76
76
  .json({error: 'Invalid or expired refresh token'});
77
77
  }
@@ -96,7 +96,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
96
96
  maxAge: accessMaxAge,
97
97
  });
98
98
 
99
- return res
99
+ res
100
100
  .status(200)
101
101
  .json({message: 'Token refreshed successfully'});
102
102
  }
@@ -104,7 +104,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
104
104
  if (req.path === '/api/callback') {
105
105
  const code = req.query.code;
106
106
  if (!code) {
107
- return res.status(400).send('No code received');
107
+ res.status(400).send('No code received');
108
108
  }
109
109
 
110
110
  const {tokens, account, redirectUrl} = await exchangeToken(
@@ -144,7 +144,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
144
144
 
145
145
  const urlToRedirect = `http://${redirectUrl}/`;
146
146
 
147
- return res.redirect(urlToRedirect);
147
+ res.redirect(urlToRedirect);
148
148
  }
149
149
  } catch (error) {
150
150
  // console.error("Error in proproAuthMiddleware:", error);
@@ -163,6 +163,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
163
163
  * @return {string} The constructed redirect URL.
164
164
  */
165
165
  function constructRedirectUrl(clientUrl, appName, clientId, redirectUri) {
166
+ console.log('constructRedirectUrl', clientUrl, appName, clientId, redirectUri);
166
167
  return `${clientUrl}/signin?response_type=code&appName=${appName}&client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}`;
167
168
  }
168
169