Add role aware updates & endpoints

This commit is contained in:
Owen Schwartz 2024-10-12 21:36:14 -04:00
parent 41cbde1474
commit 364b2c26c3
No known key found for this signature in database
GPG key ID: 8271FDFFD9E0CCBD
49 changed files with 1587 additions and 79 deletions

View file

@ -49,7 +49,7 @@ export async function createTarget(req: Request, res: Response, next: NextFuncti
// Check if the user has permission to list sites
const hasPermission = await checkUserActionPermission(ActionsEnum.createTarget, req);
if (!hasPermission) {
return next(createHttpError(HttpCode.FORBIDDEN, 'User does not have permission to list sites'));
return next(createHttpError(HttpCode.FORBIDDEN, 'User does not have permission to perform this action'));
}
const newTarget = await db.insert(targets).values({

View file

@ -30,7 +30,7 @@ export async function deleteTarget(req: Request, res: Response, next: NextFuncti
// Check if the user has permission to list sites
const hasPermission = await checkUserActionPermission(ActionsEnum.deleteTarget, req);
if (!hasPermission) {
return next(createHttpError(HttpCode.FORBIDDEN, 'User does not have permission to list sites'));
return next(createHttpError(HttpCode.FORBIDDEN, 'User does not have permission to perform this action'));
}
const deletedTarget = await db.delete(targets)

View file

@ -30,7 +30,7 @@ export async function getTarget(req: Request, res: Response, next: NextFunction)
// Check if the user has permission to list sites
const hasPermission = await checkUserActionPermission(ActionsEnum.getTarget, req);
if (!hasPermission) {
return next(createHttpError(HttpCode.FORBIDDEN, 'User does not have permission to list sites'));
return next(createHttpError(HttpCode.FORBIDDEN, 'User does not have permission to perform this action'));
}
const target = await db.select()

View file

@ -47,7 +47,7 @@ export async function listTargets(req: Request, res: Response, next: NextFunctio
// Check if the user has permission to list sites
const hasPermission = await checkUserActionPermission(ActionsEnum.listTargets, req);
if (!hasPermission) {
return next(createHttpError(HttpCode.FORBIDDEN, 'User does not have permission to list sites'));
return next(createHttpError(HttpCode.FORBIDDEN, 'User does not have permission to perform this action'));
}
let baseQuery: any = db

View file

@ -51,7 +51,7 @@ export async function updateTarget(req: Request, res: Response, next: NextFuncti
// Check if the user has permission to list sites
const hasPermission = await checkUserActionPermission(ActionsEnum.updateTarget, req);
if (!hasPermission) {
return next(createHttpError(HttpCode.FORBIDDEN, 'User does not have permission to list sites'));
return next(createHttpError(HttpCode.FORBIDDEN, 'User does not have permission to perform this action'));
}
const updatedTarget = await db.update(targets)