propro-utils 1.4.27 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.4.27",
3
+ "version": "1.4.28",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -81,6 +81,9 @@ function proproAuthMiddleware(options = {}, userSchema) {
81
81
  }
82
82
  );
83
83
 
84
+ const accessMaxAge =
85
+ new Date(access.expires).getTime() - currentDateTime.getTime();
86
+
84
87
  const { account, access, refresh } = response.data;
85
88
 
86
89
  if (!account || !access || !refresh) {
@@ -100,9 +103,6 @@ function proproAuthMiddleware(options = {}, userSchema) {
100
103
  maxAge: refreshMaxAge,
101
104
  });
102
105
 
103
- const accessMaxAge =
104
- new Date(access.expires).getTime() - currentDateTime.getTime();
105
-
106
106
  res.cookie('x-access-token', access.token, {
107
107
  httpOnly: true,
108
108
  secure: process.env.NODE_ENV === 'production',
@@ -151,9 +151,13 @@ function proproAuthMiddleware(options = {}, userSchema) {
151
151
  maxAge: accessMaxAge,
152
152
  });
153
153
 
154
- res.cookie('user', JSON.stringify(user));
154
+ res.cookie('user', JSON.stringify(user), {
155
+ maxAge: accessMaxAge,
156
+ });
155
157
 
156
- res.cookie('account', JSON.stringify(account));
158
+ res.cookie('account', JSON.stringify(account), {
159
+ maxAge: accessMaxAge,
160
+ });
157
161
 
158
162
  const urlToRedirect = formatRedirectUrl(redirectUrl);
159
163