@duvdu-v1/duvdu 1.0.21 → 1.0.23
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,13 +20,16 @@ const generic_error_1 = require("../errors/generic-error");
|
|
|
20
20
|
const unauthenticated_error_1 = require("../errors/unauthenticated-error");
|
|
21
21
|
const auth = (modelName) => ((req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
22
|
var _a, _b;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
throw new generic_error_1.GenericError('the users access is denied due to their blocked status.');
|
|
23
|
+
if (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt)) {
|
|
24
|
+
throw new unauthenticated_error_1.UnauthenticatedError();
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
const user = yield modelName.findOne({ token: (_b = req.session) === null || _b === void 0 ? void 0 : _b.jwt });
|
|
27
|
+
if (!user) {
|
|
28
28
|
throw new unauthenticated_error_1.UnauthenticatedError();
|
|
29
29
|
}
|
|
30
|
+
if (user.isBlocked) {
|
|
31
|
+
throw new generic_error_1.GenericError('the users access is denied due to their blocked status.');
|
|
32
|
+
}
|
|
30
33
|
try {
|
|
31
34
|
const payload = jsonwebtoken_1.default.verify(req.session.jwt, process.env.JWT_KEY);
|
|
32
35
|
req.user = { id: payload.id };
|