propro-utils 1.4.21 → 1.4.23
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 +9 -6
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -43,8 +43,10 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
43
43
|
return res.status(200).json({redirectUrl});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
console.log('req.path', req.path);
|
|
46
47
|
if (req.path === '/api/refreshToken') {
|
|
47
48
|
if (req.cookies) {
|
|
49
|
+
console.log('req.cookies', req.cookies);
|
|
48
50
|
refreshToken = req.cookies['x-refresh-token'];
|
|
49
51
|
}
|
|
50
52
|
// const refreshToken = req.cookies['x-refresh-token'];
|
|
@@ -55,6 +57,8 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
55
57
|
.json({redirectUrl, error: 'No refresh token provided'});
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
console.log('refreshToken', refreshToken);
|
|
61
|
+
|
|
58
62
|
const response = await post(
|
|
59
63
|
`${authUrl}/api/v1/auth/refreshTokens`,
|
|
60
64
|
{
|
|
@@ -77,6 +81,10 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
77
81
|
|
|
78
82
|
const currentDateTime = new Date();
|
|
79
83
|
|
|
84
|
+
console.log('account', account);
|
|
85
|
+
console.log('access', access);
|
|
86
|
+
console.log('refresh', refresh);
|
|
87
|
+
|
|
80
88
|
const refreshMaxAge =
|
|
81
89
|
new Date(refresh.expires).getTime() - currentDateTime.getTime();
|
|
82
90
|
|
|
@@ -107,7 +115,6 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
107
115
|
return res.status(400).send('No code received');
|
|
108
116
|
}
|
|
109
117
|
|
|
110
|
-
console.log('code', code);
|
|
111
118
|
const {tokens, account, redirectUrl} = await exchangeToken(
|
|
112
119
|
authUrl,
|
|
113
120
|
code,
|
|
@@ -116,9 +123,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
116
123
|
redirectUri
|
|
117
124
|
);
|
|
118
125
|
|
|
119
|
-
console.log('tokens', tokens);
|
|
120
126
|
const user = await checkIfUserExists(userSchema, account.accountId);
|
|
121
|
-
console.log('user', user);
|
|
122
127
|
|
|
123
128
|
const currentDateTime = new Date();
|
|
124
129
|
|
|
@@ -149,11 +154,9 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
149
154
|
|
|
150
155
|
res.cookie('account', JSON.stringify(account));
|
|
151
156
|
|
|
152
|
-
console.log('redirectUrl', redirectUrl);
|
|
153
157
|
|
|
154
|
-
const urlToRedirect = formatRedirectUrl(
|
|
158
|
+
const urlToRedirect = formatRedirectUrl(redirectUrl);
|
|
155
159
|
|
|
156
|
-
console.log('urlToRedirect', urlToRedirect);
|
|
157
160
|
|
|
158
161
|
return res.redirect(urlToRedirect);
|
|
159
162
|
}
|