@misalon/common 1.0.13 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
package/build/index.d.ts
CHANGED
@@ -8,7 +8,6 @@ export * from './middlewares/current-user';
|
|
8
8
|
export * from './middlewares/error-handler';
|
9
9
|
export * from './middlewares/require-auth';
|
10
10
|
export * from './middlewares/validate-request';
|
11
|
-
export * from './middlewares/admin-auth';
|
12
11
|
export * from './middlewares/restrict-by-role';
|
13
12
|
export * from './events/base-listener';
|
14
13
|
export * from './events/base-publisher';
|
package/build/index.js
CHANGED
@@ -24,7 +24,6 @@ __exportStar(require("./middlewares/current-user"), exports);
|
|
24
24
|
__exportStar(require("./middlewares/error-handler"), exports);
|
25
25
|
__exportStar(require("./middlewares/require-auth"), exports);
|
26
26
|
__exportStar(require("./middlewares/validate-request"), exports);
|
27
|
-
__exportStar(require("./middlewares/admin-auth"), exports);
|
28
27
|
__exportStar(require("./middlewares/restrict-by-role"), exports);
|
29
28
|
__exportStar(require("./events/base-listener"), exports);
|
30
29
|
__exportStar(require("./events/base-publisher"), exports);
|
@@ -5,6 +5,11 @@ exports.restrictByRole = void 0;
|
|
5
5
|
var not_authorized_error_1 = require("../errors/not-authorized-error"); // Adjust path as needed
|
6
6
|
var restrictByRole = function (restrictedRoles) {
|
7
7
|
return function (req, res, next) {
|
8
|
+
if (!req.currentUser) {
|
9
|
+
// If user is not authenticated, return a 401 error
|
10
|
+
res.status(401).send({ error: 'User not authenticated' });
|
11
|
+
return;
|
12
|
+
}
|
8
13
|
if (restrictedRoles.includes(req.currentUser.role)) {
|
9
14
|
throw new not_authorized_error_1.NotAuthorizedError();
|
10
15
|
}
|