propro-utils 1.4.39 → 1.4.40

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server/index.js +20 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.4.39",
3
+ "version": "1.4.40",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -106,17 +106,25 @@ function proproAuthMiddleware(options = {}, userSchema) {
106
106
 
107
107
  const formatedAuthUrl = formatRedirectUrl(authUrl);
108
108
 
109
- const response = await post(
110
- `${formatedAuthUrl}/api/v1/auth/refreshTokens`,
111
- {
112
- refreshToken,
113
- },
114
- {
115
- params: {
116
- actionType: 'refresh',
109
+ console.log('making a refreshToken Request: ', refreshToken);
110
+
111
+ let response;
112
+
113
+ try {
114
+ response = await post(
115
+ `${formatedAuthUrl}/api/v1/auth/refreshTokens`,
116
+ {
117
+ refreshToken,
117
118
  },
118
- }
119
- );
119
+ {
120
+ params: {
121
+ actionType: 'refresh',
122
+ },
123
+ }
124
+ );
125
+ } catch (error) {
126
+ console.error('an error occur: ', error);
127
+ }
120
128
 
121
129
  const { account, access, refresh } = response.data;
122
130
 
@@ -126,6 +134,8 @@ function proproAuthMiddleware(options = {}, userSchema) {
126
134
  .json({ error: 'Invalid or expired refresh token' });
127
135
  }
128
136
 
137
+ console.log('Checking for existing user: ', account);
138
+
129
139
  const user = await checkIfUserExists(userSchema, account.accountId);
130
140
 
131
141
  console.log('Setting Cookies: ', user, account);