@naturalcycles/backend-lib 9.68.0 → 9.69.0
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.
|
@@ -21,6 +21,7 @@ export function requireAdminPermissions(adminService, reqPermissions = [], cfg =
|
|
|
21
21
|
return next();
|
|
22
22
|
try {
|
|
23
23
|
await adminService.requirePermissions(req, reqPermissions, {}, andComparison);
|
|
24
|
+
req.isAuthenticatedAdminRequest = true;
|
|
24
25
|
return next();
|
|
25
26
|
}
|
|
26
27
|
catch (err) {
|
|
@@ -38,6 +38,11 @@ export interface BackendRequest<BODY = unknown> extends Request {
|
|
|
38
38
|
*/
|
|
39
39
|
requestTimeout?: NodeJS.Timeout;
|
|
40
40
|
bodyParserTimeout?: NodeJS.Timeout;
|
|
41
|
+
/**
|
|
42
|
+
* When `true`, the request originated from an authenticated admin account.
|
|
43
|
+
* When not `true`, then we can make no claim either way.
|
|
44
|
+
*/
|
|
45
|
+
isAuthenticatedAdminRequest?: true;
|
|
41
46
|
}
|
|
42
47
|
export type BackendResponse = Response;
|
|
43
48
|
export type BackendRequestHandler = (req: BackendRequest, res: BackendResponse, next: NextFunction) => Promisable<any>;
|
package/package.json
CHANGED
|
@@ -75,6 +75,7 @@ export function requireAdminPermissions(
|
|
|
75
75
|
|
|
76
76
|
try {
|
|
77
77
|
await adminService.requirePermissions(req, reqPermissions, {}, andComparison)
|
|
78
|
+
req.isAuthenticatedAdminRequest = true
|
|
78
79
|
return next()
|
|
79
80
|
} catch (err) {
|
|
80
81
|
if (err instanceof AppError && err.data.adminAuthRequired) {
|
|
@@ -44,6 +44,12 @@ export interface BackendRequest<BODY = unknown> extends Request {
|
|
|
44
44
|
requestTimeout?: NodeJS.Timeout
|
|
45
45
|
|
|
46
46
|
bodyParserTimeout?: NodeJS.Timeout
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* When `true`, the request originated from an authenticated admin account.
|
|
50
|
+
* When not `true`, then we can make no claim either way.
|
|
51
|
+
*/
|
|
52
|
+
isAuthenticatedAdminRequest?: true
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
export type BackendResponse = Response
|