propro-utils 1.4.49 → 1.4.51
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
package/src/server/index.js
CHANGED
|
@@ -56,7 +56,6 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
56
56
|
if (req.cookies) {
|
|
57
57
|
refreshToken = req.cookies['x-refresh-token'];
|
|
58
58
|
}
|
|
59
|
-
console.log('refreshing tokens: ', refreshToken);
|
|
60
59
|
if (!refreshToken) {
|
|
61
60
|
const redirectUrl = constructRedirectUrl(
|
|
62
61
|
clientUrl,
|
|
@@ -121,13 +120,9 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
121
120
|
);
|
|
122
121
|
|
|
123
122
|
const user = await checkIfUserExists(userSchema, account.accountId);
|
|
124
|
-
console.log('user: ', user);
|
|
125
123
|
|
|
126
|
-
console.log('setting cookies: ', tokens, account, user);
|
|
127
124
|
setAuthCookies(res, tokens, account, user);
|
|
128
125
|
|
|
129
|
-
console.log('setting cookies and redirectUrl: ', redirectUrl);
|
|
130
|
-
|
|
131
126
|
const urlToRedirect = formatRedirectUrl(redirectUrl);
|
|
132
127
|
|
|
133
128
|
return res.redirect(urlToRedirect);
|
|
@@ -11,30 +11,36 @@ const setAuthCookies = (res, tokens, account, user) => {
|
|
|
11
11
|
|
|
12
12
|
const refreshMaxAge =
|
|
13
13
|
new Date(tokens.refresh.expires).getTime() - currentDateTime.getTime();
|
|
14
|
+
const accessMaxAge =
|
|
15
|
+
new Date(tokens.access.expires).getTime() - currentDateTime.getTime();
|
|
16
|
+
|
|
17
|
+
const commonAttributes = {
|
|
18
|
+
secure: process.env.NODE_ENV === 'production',
|
|
19
|
+
sameSite: 'Strict',
|
|
20
|
+
path: '/',
|
|
21
|
+
domain: 'app.mapmap.app',
|
|
22
|
+
};
|
|
14
23
|
|
|
15
24
|
res.cookie('x-refresh-token', tokens.refresh.token, {
|
|
16
25
|
httpOnly: true,
|
|
17
|
-
secure: process.env.NODE_ENV === 'production',
|
|
18
26
|
maxAge: refreshMaxAge,
|
|
27
|
+
...commonAttributes,
|
|
19
28
|
});
|
|
20
29
|
|
|
21
|
-
const accessMaxAge =
|
|
22
|
-
new Date(tokens.access.expires).getTime() - currentDateTime.getTime();
|
|
23
|
-
|
|
24
30
|
res.cookie('x-access-token', tokens.access.token, {
|
|
25
31
|
httpOnly: true,
|
|
26
|
-
secure: process.env.NODE_ENV === 'production',
|
|
27
32
|
maxAge: accessMaxAge,
|
|
33
|
+
...commonAttributes,
|
|
28
34
|
});
|
|
29
35
|
|
|
30
36
|
res.cookie('user', JSON.stringify(user), {
|
|
31
37
|
maxAge: refreshMaxAge,
|
|
32
|
-
|
|
38
|
+
...commonAttributes,
|
|
33
39
|
});
|
|
34
40
|
|
|
35
41
|
res.cookie('account', JSON.stringify(account), {
|
|
36
42
|
maxAge: refreshMaxAge,
|
|
37
|
-
|
|
43
|
+
...commonAttributes,
|
|
38
44
|
});
|
|
39
45
|
|
|
40
46
|
res.cookie(
|
|
@@ -42,7 +48,7 @@ const setAuthCookies = (res, tokens, account, user) => {
|
|
|
42
48
|
JSON.stringify({ value: 'true', expires: accessMaxAge }),
|
|
43
49
|
{
|
|
44
50
|
maxAge: accessMaxAge,
|
|
45
|
-
|
|
51
|
+
...commonAttributes,
|
|
46
52
|
}
|
|
47
53
|
);
|
|
48
54
|
};
|