propro-utils 1.5.8 → 1.5.10
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.
|
@@ -35,6 +35,9 @@ const { checkIfUserExists } = require('./account_info');
|
|
|
35
35
|
*/
|
|
36
36
|
const authValidation = (redisClient, userSchema, requiredPermissions = []) => {
|
|
37
37
|
return async (req, res, next) => {
|
|
38
|
+
console.log('authValidation middleware');
|
|
39
|
+
console.log('req.cookies', JSON.stringify(req.cookies));
|
|
40
|
+
console.log('req.headers', JSON.stringify(req.headers));
|
|
38
41
|
try {
|
|
39
42
|
const accessToken =
|
|
40
43
|
req.cookies['x-access-token'] ||
|
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -155,7 +155,8 @@ class AuthMiddleware {
|
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
handleRefreshToken = async (req, res) => {
|
|
158
|
-
const refreshToken =
|
|
158
|
+
const refreshToken =
|
|
159
|
+
req.cookies['x-refresh-token'] || req.headers['x-refresh-token'];
|
|
159
160
|
if (!refreshToken) {
|
|
160
161
|
return res.status(401).json({
|
|
161
162
|
redirectUrl: this.constructRedirectUrl(),
|
|
@@ -174,6 +175,11 @@ class AuthMiddleware {
|
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
const user = await checkIfUserExists(this.userSchema, account.accountId);
|
|
178
|
+
|
|
179
|
+
const { returnTokens } = req.query;
|
|
180
|
+
if (returnTokens === 'true') {
|
|
181
|
+
return res.status(200).json({ account, user, access, refresh });
|
|
182
|
+
}
|
|
177
183
|
setAuthCookies(
|
|
178
184
|
res,
|
|
179
185
|
{ access, refresh },
|