propro-utils 1.4.26 → 1.4.28
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 -11
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -67,8 +67,6 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
67
67
|
.json({ redirectUrl, error: 'No refresh token provided' });
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
console.log('refreshToken', refreshToken);
|
|
71
|
-
|
|
72
70
|
const formatedAuthUrl = formatRedirectUrl(authUrl);
|
|
73
71
|
|
|
74
72
|
const response = await post(
|
|
@@ -83,9 +81,10 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
83
81
|
}
|
|
84
82
|
);
|
|
85
83
|
|
|
86
|
-
const
|
|
84
|
+
const accessMaxAge =
|
|
85
|
+
new Date(access.expires).getTime() - currentDateTime.getTime();
|
|
87
86
|
|
|
88
|
-
|
|
87
|
+
const { account, access, refresh } = response.data;
|
|
89
88
|
|
|
90
89
|
if (!account || !access || !refresh) {
|
|
91
90
|
return res
|
|
@@ -104,17 +103,12 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
104
103
|
maxAge: refreshMaxAge,
|
|
105
104
|
});
|
|
106
105
|
|
|
107
|
-
const accessMaxAge =
|
|
108
|
-
new Date(access.expires).getTime() - currentDateTime.getTime();
|
|
109
|
-
|
|
110
106
|
res.cookie('x-access-token', access.token, {
|
|
111
107
|
httpOnly: true,
|
|
112
108
|
secure: process.env.NODE_ENV === 'production',
|
|
113
109
|
maxAge: accessMaxAge,
|
|
114
110
|
});
|
|
115
111
|
|
|
116
|
-
console.log('account', account);
|
|
117
|
-
|
|
118
112
|
return res
|
|
119
113
|
.status(200)
|
|
120
114
|
.json({ message: 'Token refreshed successfully' });
|
|
@@ -157,9 +151,13 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
157
151
|
maxAge: accessMaxAge,
|
|
158
152
|
});
|
|
159
153
|
|
|
160
|
-
res.cookie('user', JSON.stringify(user)
|
|
154
|
+
res.cookie('user', JSON.stringify(user), {
|
|
155
|
+
maxAge: accessMaxAge,
|
|
156
|
+
});
|
|
161
157
|
|
|
162
|
-
res.cookie('account', JSON.stringify(account)
|
|
158
|
+
res.cookie('account', JSON.stringify(account), {
|
|
159
|
+
maxAge: accessMaxAge,
|
|
160
|
+
});
|
|
163
161
|
|
|
164
162
|
const urlToRedirect = formatRedirectUrl(redirectUrl);
|
|
165
163
|
|