propro-utils 1.4.10 → 1.4.12

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.10",
3
+ "version": "1.4.12",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -38,7 +38,6 @@ function proproAuthMiddleware(options = {}, userSchema) {
38
38
  return next();
39
39
  }
40
40
 
41
- console.log('req.path', req.path);
42
41
  if (req.path === '/api/auth') {
43
42
  const redirectUrl = constructRedirectUrl(clientUrl, appName, clientId, redirectUri);
44
43
  return res.status(200).json({redirectUrl});
@@ -101,9 +100,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
101
100
  .json({message: 'Token refreshed successfully'});
102
101
  }
103
102
 
104
- console.log('req.path', req.path);
105
- console.log('req.query', req.query);
106
- console.log('authUrl', authUrl);
103
+
107
104
  if (req.path === '/api/callback') {
108
105
  const code = req.query.code;
109
106
  if (!code) {
@@ -126,12 +123,14 @@ function proproAuthMiddleware(options = {}, userSchema) {
126
123
  new Date(tokens.refresh.expires).getTime() -
127
124
  currentDateTime.getTime();
128
125
 
126
+
129
127
  res.cookie('x-refresh-token', tokens.refresh.token, {
130
128
  httpOnly: true,
131
129
  secure: process.env.NODE_ENV === 'production',
132
130
  maxAge: refreshMaxAge,
133
131
  });
134
132
 
133
+
135
134
  const accessMaxAge =
136
135
  new Date(tokens.access.expires).getTime() - currentDateTime.getTime();
137
136
 
@@ -141,10 +140,12 @@ function proproAuthMiddleware(options = {}, userSchema) {
141
140
  maxAge: accessMaxAge,
142
141
  });
143
142
 
143
+
144
144
  res.cookie('user', JSON.stringify(user));
145
145
 
146
- res.cookie('account', JSON.stringify(account));
147
146
 
147
+ res.cookie('account', JSON.stringify(account));
148
+
148
149
  const urlToRedirect = `http://${redirectUrl}/`;
149
150
 
150
151
  return res.redirect(urlToRedirect);