propro-utils 1.4.10 → 1.4.11
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 +13 -3
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -101,9 +101,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
101
101
|
.json({message: 'Token refreshed successfully'});
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
console.log('req.query', req.query);
|
|
106
|
-
console.log('authUrl', authUrl);
|
|
104
|
+
|
|
107
105
|
if (req.path === '/api/callback') {
|
|
108
106
|
const code = req.query.code;
|
|
109
107
|
if (!code) {
|
|
@@ -118,7 +116,9 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
118
116
|
redirectUri
|
|
119
117
|
);
|
|
120
118
|
|
|
119
|
+
console.log("checkIfUserExists", account.accountId)
|
|
121
120
|
const user = await checkIfUserExists(userSchema, account.accountId);
|
|
121
|
+
console.log("user", user)
|
|
122
122
|
|
|
123
123
|
const currentDateTime = new Date();
|
|
124
124
|
|
|
@@ -126,12 +126,16 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
126
126
|
new Date(tokens.refresh.expires).getTime() -
|
|
127
127
|
currentDateTime.getTime();
|
|
128
128
|
|
|
129
|
+
console.log("setting cookies")
|
|
130
|
+
|
|
129
131
|
res.cookie('x-refresh-token', tokens.refresh.token, {
|
|
130
132
|
httpOnly: true,
|
|
131
133
|
secure: process.env.NODE_ENV === 'production',
|
|
132
134
|
maxAge: refreshMaxAge,
|
|
133
135
|
});
|
|
134
136
|
|
|
137
|
+
console.log("setting cookies")
|
|
138
|
+
|
|
135
139
|
const accessMaxAge =
|
|
136
140
|
new Date(tokens.access.expires).getTime() - currentDateTime.getTime();
|
|
137
141
|
|
|
@@ -141,10 +145,16 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
141
145
|
maxAge: accessMaxAge,
|
|
142
146
|
});
|
|
143
147
|
|
|
148
|
+
console.log("setting cookies")
|
|
149
|
+
|
|
144
150
|
res.cookie('user', JSON.stringify(user));
|
|
145
151
|
|
|
152
|
+
console.log("setting cookies")
|
|
153
|
+
|
|
146
154
|
res.cookie('account', JSON.stringify(account));
|
|
147
155
|
|
|
156
|
+
console.log("setting cookies", redirectUrl)
|
|
157
|
+
|
|
148
158
|
const urlToRedirect = `http://${redirectUrl}/`;
|
|
149
159
|
|
|
150
160
|
return res.redirect(urlToRedirect);
|