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