@duvdu-v1/duvdu 1.0.31 → 1.0.33
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.
|
@@ -13,10 +13,10 @@ exports.isAuthorized = void 0;
|
|
|
13
13
|
const unauthorized_error_1 = require("../errors/unauthorized-error");
|
|
14
14
|
const isAuthorized = (planModel, roleMode, permission) => ((req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
var _a;
|
|
16
|
-
const plan = yield planModel.
|
|
16
|
+
const plan = yield planModel.findById((_a = req.loggedUser) === null || _a === void 0 ? void 0 : _a.planId);
|
|
17
17
|
if (!plan)
|
|
18
18
|
return next(new unauthorized_error_1.UnauthorizedError('user dont have plain'));
|
|
19
|
-
const role = yield roleMode.
|
|
19
|
+
const role = yield roleMode.findById(plan.role);
|
|
20
20
|
if (!role)
|
|
21
21
|
return next(new unauthorized_error_1.UnauthorizedError('user dont have this role'));
|
|
22
22
|
if (!role.features.includes(permission))
|