propro-utils 1.4.38 → 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.
- package/package.json +1 -1
- package/src/server/index.js +24 -10
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -106,17 +106,25 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
106
106
|
|
|
107
107
|
const formatedAuthUrl = formatRedirectUrl(authUrl);
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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,10 +134,16 @@ 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
|
|
|
141
|
+
console.log('Setting Cookies: ', user, account);
|
|
142
|
+
|
|
131
143
|
setAuthCookies(res, { access, refresh }, account, user);
|
|
132
144
|
|
|
145
|
+
console.log('Cookies Set: ');
|
|
146
|
+
|
|
133
147
|
return res
|
|
134
148
|
.status(200)
|
|
135
149
|
.json({ message: 'Token refreshed successfully' });
|