Add auth actions on cars list. Comment 'canRead' - not needed yet
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -710,12 +710,12 @@ export default class AuthorizationService {
filteredRequest: Record<string, any>): Promise<void> {
// Enrich
if (!car) {
- car.canRead = true;
+ // car.canRead = true;
car.canUpdate = false;
car.canDelete = false;
} else {
filteredRequest.SiteID = car.id;
- car.canRead = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.CAR, Action.READ, authorizationFilter, filteredRequest);
+ // car.canRead = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.CAR, Action.READ, authorizationFilter, filteredRequest);
car.canDelete = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.CAR, Action.DELETE, authorizationFilter, filteredRequest);
car.canUpdate = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.CAR, Action.UPDATE, authorizationFilter, filteredRequest);
}

MODIFY
src/server/rest/v1/service/CarService.ts
src/server/rest/v1/service/CarService.ts
@@ -9,6 +9,7 @@ import AppError from '../../../../exception/AppError';
import AsyncTaskManager from '../../../../async-task/AsyncTaskManager';
import AuthorizationService from './AuthorizationService';
import Authorizations from '../../../../authorization/Authorizations';
+import { CarDataResult } from '../../../../types/DataResult';
import CarSecurity from './security/CarSecurity';
import CarStorage from '../../../../storage/mongodb/CarStorage';
import Constants from '../../../../utils/Constants';
@@ -430,6 +431,9 @@ export default class CarService {
},
authorizationCarsFilter.projectFields
);
+ // Add Auth flags
+ await AuthorizationService.addCarsAuthorizations(
+ req.tenant, req.user, cars as CarDataResult, authorizationCarsFilter, filteredRequest);
// Return
res.json(cars);
next();

Add auth actions on cars list. Comment 'canRead' - not needed yet