propro-utils 1.4.8 → 1.4.9
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 +6 -6
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -41,7 +41,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
41
41
|
console.log('req.path', req.path);
|
|
42
42
|
if (req.path === '/api/auth') {
|
|
43
43
|
const redirectUrl = constructRedirectUrl(clientUrl, appName, clientId, redirectUri);
|
|
44
|
-
res.status(200).json({redirectUrl});
|
|
44
|
+
return res.status(200).json({redirectUrl});
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
if (req.path === '/api/refreshToken') {
|
|
@@ -51,7 +51,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
51
51
|
// const refreshToken = req.cookies['x-refresh-token'];
|
|
52
52
|
if (!refreshToken) {
|
|
53
53
|
const redirectUrl = constructRedirectUrl(clientUrl, appName, clientId, redirectUri);
|
|
54
|
-
res
|
|
54
|
+
return res
|
|
55
55
|
.status(401)
|
|
56
56
|
.json({redirectUrl, error: 'No refresh token provided'});
|
|
57
57
|
}
|
|
@@ -71,7 +71,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
71
71
|
const {account, access, refresh} = response.data;
|
|
72
72
|
|
|
73
73
|
if (!account || !access || !refresh) {
|
|
74
|
-
res
|
|
74
|
+
return res
|
|
75
75
|
.status(401)
|
|
76
76
|
.json({error: 'Invalid or expired refresh token'});
|
|
77
77
|
}
|
|
@@ -96,7 +96,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
96
96
|
maxAge: accessMaxAge,
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
res
|
|
99
|
+
return res
|
|
100
100
|
.status(200)
|
|
101
101
|
.json({message: 'Token refreshed successfully'});
|
|
102
102
|
}
|
|
@@ -104,7 +104,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
104
104
|
if (req.path === '/api/callback') {
|
|
105
105
|
const code = req.query.code;
|
|
106
106
|
if (!code) {
|
|
107
|
-
res.status(400).send('No code received');
|
|
107
|
+
return res.status(400).send('No code received');
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const {tokens, account, redirectUrl} = await exchangeToken(
|
|
@@ -144,7 +144,7 @@ function proproAuthMiddleware(options = {}, userSchema) {
|
|
|
144
144
|
|
|
145
145
|
const urlToRedirect = `http://${redirectUrl}/`;
|
|
146
146
|
|
|
147
|
-
res.redirect(urlToRedirect);
|
|
147
|
+
return res.redirect(urlToRedirect);
|
|
148
148
|
}
|
|
149
149
|
} catch (error) {
|
|
150
150
|
// console.error("Error in proproAuthMiddleware:", error);
|