@munlib/common 1.0.33 → 1.0.36
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.
|
@@ -7,15 +7,14 @@ exports.requireAuth = void 0;
|
|
|
7
7
|
var not_authorized_error_1 = require("../errors/not-authorized-error");
|
|
8
8
|
var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
9
9
|
var requireAuth = function (req, res, next) {
|
|
10
|
-
var _a
|
|
10
|
+
var _a;
|
|
11
11
|
if (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt)) {
|
|
12
|
-
console.log("****", (_b = req.session) === null || _b === void 0 ? void 0 : _b.jwt, !((_c = req.session) === null || _c === void 0 ? void 0 : _c.jwt));
|
|
13
12
|
// Si no hay un token JWT en la sesión, devolver Unauthorized
|
|
14
13
|
throw new not_authorized_error_1.NotAuthorizedError();
|
|
15
14
|
}
|
|
16
15
|
try {
|
|
17
16
|
var payload = jsonwebtoken_1.default.verify(req.session.jwt, process.env.JWT_KEY);
|
|
18
|
-
req.
|
|
17
|
+
req.currentUser = payload;
|
|
19
18
|
}
|
|
20
19
|
catch (err) {
|
|
21
20
|
throw new not_authorized_error_1.NotAuthorizedError();
|