@riocrypto/common-server 1.0.2196 → 1.0.2197
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.
|
@@ -20,12 +20,8 @@ const auth_1 = require("../models/auth");
|
|
|
20
20
|
const apiKey_1 = require("../services/apiKey");
|
|
21
21
|
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
22
22
|
const admin_auth_1 = require("../models/admin-auth");
|
|
23
|
-
const logger_1 = __importDefault(require("../services/logger"));
|
|
24
23
|
const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
24
|
var _a, _b;
|
|
26
|
-
// Start performance monitoring
|
|
27
|
-
const logger = logger_1.default.getLogger();
|
|
28
|
-
const startTime = Date.now();
|
|
29
25
|
// Early return for public routes
|
|
30
26
|
if (authorizationTypes.includes(common_1.AuthorizationType.Public)) {
|
|
31
27
|
next();
|
|
@@ -179,14 +175,9 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
179
175
|
((authorizationTypes.includes(common_1.AuthorizationType.User) ||
|
|
180
176
|
authorizationTypes.includes(common_1.AuthorizationType.UserNoKYC)) &&
|
|
181
177
|
req.user)) {
|
|
182
|
-
const endTime = Date.now();
|
|
183
|
-
logger.info(`Authorization completed in ${endTime - startTime}ms`);
|
|
184
178
|
next();
|
|
185
179
|
return;
|
|
186
180
|
}
|
|
187
|
-
// Log unauthorized attempt
|
|
188
|
-
const endTime = Date.now();
|
|
189
|
-
logger.info(`Authorization failed in ${endTime - startTime}ms`);
|
|
190
181
|
throw new common_1.NotAuthorizedError();
|
|
191
182
|
});
|
|
192
183
|
exports.authorize = authorize;
|