@wrcb/cb-common 1.0.56 → 1.0.57
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.
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from 'express';
|
|
2
|
-
interface UserPayload {
|
|
2
|
+
export interface UserPayload {
|
|
3
3
|
id: string;
|
|
4
4
|
email: string;
|
|
5
|
-
|
|
6
|
-
role: string;
|
|
5
|
+
role?: string;
|
|
7
6
|
}
|
|
8
7
|
declare global {
|
|
9
8
|
namespace Express {
|
|
@@ -13,4 +12,3 @@ declare global {
|
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
export declare const currentUser: (req: Request, res: Response, next: NextFunction) => void;
|
|
16
|
-
export {};
|
|
@@ -6,7 +6,7 @@ const userRole_1 = require("../events/types/userRole");
|
|
|
6
6
|
const requireAdmin = (req, res, next) => {
|
|
7
7
|
var _a;
|
|
8
8
|
if (((_a = req.currentUser) === null || _a === void 0 ? void 0 : _a.role) !== userRole_1.UserRole.Admin) {
|
|
9
|
-
throw new notAuthorizedError_1.NotAuthorizedError('
|
|
9
|
+
throw new notAuthorizedError_1.NotAuthorizedError('Não autorizado - apenas administrador');
|
|
10
10
|
}
|
|
11
11
|
next();
|
|
12
12
|
};
|
|
@@ -4,7 +4,7 @@ exports.requireAuth = void 0;
|
|
|
4
4
|
const notAuthorizedError_1 = require("../errors/notAuthorizedError");
|
|
5
5
|
const requireAuth = (req, res, next) => {
|
|
6
6
|
if (!req.currentUser) {
|
|
7
|
-
throw new notAuthorizedError_1.NotAuthorizedError('
|
|
7
|
+
throw new notAuthorizedError_1.NotAuthorizedError('Não autorizado');
|
|
8
8
|
}
|
|
9
9
|
next();
|
|
10
10
|
};
|
package/build/types/index.d.ts
CHANGED