propro-utils 1.4.93 → 1.4.95

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.93",
3
+ "version": "1.4.95",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -207,7 +207,8 @@ class AuthMiddleware {
207
207
  };
208
208
 
209
209
  handleLogout = async (req, res) => {
210
- const refreshToken = req.cookies['x-refresh-token'];
210
+ const refreshToken =
211
+ req.cookies['x-refresh-token'] || req.headers['x-refresh-token'];
211
212
  if (!refreshToken) {
212
213
  return res.status(401).json({ error: 'No refresh token provided' });
213
214
  }
@@ -332,10 +333,17 @@ class AuthMiddleware {
332
333
  headers.Authorization = `Bearer ${accessToken}`;
333
334
  }
334
335
 
335
- const formattedAuthUrl = formatRedirectUrl(this.options.authUrl);
336
+ let formattedAuthUrl = formatRedirectUrl(this.options.authUrl);
337
+
338
+ if (!accessToken) {
339
+ formattedAuthUrl = `${formattedAuthUrl}&clientId=${this.options.clientId}&redirectUri=${this.options.redirectUri}`;
340
+ }
341
+
342
+ console.log('formattedAuthUrl:', formattedAuthUrl);
343
+ console.log('req.method:', req.method);
336
344
  return axios({
337
345
  method: req.method,
338
- url: `${formattedAuthUrl}${path}&clientId=${this.options.clientId}&redirectUri=${this.options.redirectUri}`,
346
+ url: `${formattedAuthUrl}${path}`,
339
347
  data: req.body,
340
348
  headers: headers,
341
349
  });