propro-utils 1.4.82 → 1.4.84
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 +19 -5
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -71,9 +71,12 @@ class AuthMiddleware {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
handleLogin = async (req, res) => {
|
|
74
|
-
const { email,
|
|
74
|
+
const { email, name, password } = req.body;
|
|
75
75
|
const { returnTokens } = req.query;
|
|
76
76
|
|
|
77
|
+
console.log('returnTokens:', returnTokens);
|
|
78
|
+
console.log('email:', email);
|
|
79
|
+
|
|
77
80
|
try {
|
|
78
81
|
const response = await this.proxyToAuthServer(
|
|
79
82
|
req,
|
|
@@ -81,7 +84,7 @@ class AuthMiddleware {
|
|
|
81
84
|
'POST',
|
|
82
85
|
{
|
|
83
86
|
email,
|
|
84
|
-
|
|
87
|
+
name,
|
|
85
88
|
password,
|
|
86
89
|
clientId: this.options.clientId,
|
|
87
90
|
redirectUri: this.options.redirectUri,
|
|
@@ -89,6 +92,8 @@ class AuthMiddleware {
|
|
|
89
92
|
}
|
|
90
93
|
);
|
|
91
94
|
|
|
95
|
+
console.log('response:', JSON.stringify(response.data));
|
|
96
|
+
|
|
92
97
|
const { account, tokens } = response.data;
|
|
93
98
|
const user = await checkIfUserExists(this.userSchema, account.accountId);
|
|
94
99
|
|
|
@@ -302,10 +307,19 @@ class AuthMiddleware {
|
|
|
302
307
|
}
|
|
303
308
|
};
|
|
304
309
|
|
|
310
|
+
pathRequiresAccessToken = path => {
|
|
311
|
+
return (
|
|
312
|
+
!path.includes('/api/v1/auth/login') &&
|
|
313
|
+
!path.includes('/api/v1/auth/register')
|
|
314
|
+
);
|
|
315
|
+
};
|
|
316
|
+
|
|
305
317
|
proxyToAuthServer = async (req, path) => {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
318
|
+
if (this.pathRequiresAccessToken(path)) {
|
|
319
|
+
const accessToken = req.cookies['x-access-token'];
|
|
320
|
+
if (!accessToken) {
|
|
321
|
+
throw new Error('No access token provided');
|
|
322
|
+
}
|
|
309
323
|
}
|
|
310
324
|
|
|
311
325
|
const formattedAuthUrl = formatRedirectUrl(this.options.authUrl);
|