propro-utils 1.7.27 → 1.7.29
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.
|
@@ -42,6 +42,7 @@ const authValidation = (requiredPermissions = []) => {
|
|
|
42
42
|
req.headers.authorization?.split(' ')[1];
|
|
43
43
|
|
|
44
44
|
if (!accessToken) {
|
|
45
|
+
console.log('Access token is required');
|
|
45
46
|
return res.status(403).json({ error: 'Access token is required' });
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -65,6 +66,7 @@ const authValidation = (requiredPermissions = []) => {
|
|
|
65
66
|
);
|
|
66
67
|
|
|
67
68
|
if (!validPermissions) {
|
|
69
|
+
console.log('Invalid permissions');
|
|
68
70
|
return res.status(403).json({ error: 'Invalid permissions' });
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -72,9 +74,10 @@ const authValidation = (requiredPermissions = []) => {
|
|
|
72
74
|
|
|
73
75
|
let user = null;
|
|
74
76
|
try {
|
|
75
|
-
user = await checkIfUserExists(
|
|
77
|
+
user = await checkIfUserExists(accountId);
|
|
76
78
|
if (!user) throw new Error('User not found');
|
|
77
79
|
} catch (error) {
|
|
80
|
+
console.log('User not found 1');
|
|
78
81
|
return res.status(403).json({error: error?.message || 'User not found'});
|
|
79
82
|
}
|
|
80
83
|
|
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -93,12 +93,13 @@ class AuthMiddleware {
|
|
|
93
93
|
const response = await this.proxyToAuthServer(req, `/api/v1/auth/login`);
|
|
94
94
|
|
|
95
95
|
const { account, tokens } = response.data;
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
let user = null;
|
|
98
98
|
try {
|
|
99
99
|
user = await checkIfUserExists(account.accountId);
|
|
100
100
|
if (!user) throw new Error('User not found');
|
|
101
101
|
} catch (error) {
|
|
102
|
+
console.log('User not found 2');
|
|
102
103
|
return res.status(403).json({error: error?.message || 'User not found'});
|
|
103
104
|
}
|
|
104
105
|
|
|
@@ -170,6 +171,7 @@ class AuthMiddleware {
|
|
|
170
171
|
user = await checkIfUserExists(account.accountId);
|
|
171
172
|
if (!user) throw new Error('User not found');
|
|
172
173
|
} catch (error) {
|
|
174
|
+
console.log('User not found 3');
|
|
173
175
|
return res.status(403).json({error: error?.message || 'User not found'});
|
|
174
176
|
}
|
|
175
177
|
|
|
@@ -96,6 +96,7 @@ const VerifyAccount = requiredPermissions => {
|
|
|
96
96
|
try {
|
|
97
97
|
const decoded = jwt.verify(accessToken, process.env.JWT_SECRET);
|
|
98
98
|
if (!isValid(decoded, requiredPermissions)) {
|
|
99
|
+
console.log('Invalid permissions 1');
|
|
99
100
|
return res.status(403).json({ error: 'Invalid permissions' });
|
|
100
101
|
}
|
|
101
102
|
tokenCache.set(accessToken, decoded);
|
|
@@ -113,7 +114,8 @@ const VerifyAccount = requiredPermissions => {
|
|
|
113
114
|
);
|
|
114
115
|
|
|
115
116
|
if (!isValid(userResponse.data, requiredPermissions)) {
|
|
116
|
-
|
|
117
|
+
console.log('Invalid permissions 2');
|
|
118
|
+
return res.status(403).json({ error: 'Invalid permissions' });
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
tokenCache.set(accessToken, userResponse.data);
|