Fixed auth refactoring issues
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -231,7 +231,9 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
resource: Entity.CARS, action: Action.LIST, attributes: [
'id', 'type', 'vin', 'licensePlate', 'converter', 'default', 'owner', 'createdOn', 'lastChangedOn',
'carCatalog.id', 'carCatalog.vehicleMake', 'carCatalog.vehicleModel', 'carCatalog.vehicleModelVersion',
- 'carCatalog.image', 'carCatalog.fastChargePowerMax', 'carCatalog.batteryCapacityFull'
+ 'carCatalog.image', 'carCatalog.fastChargePowerMax', 'carCatalog.batteryCapacityFull',
+ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName',
+ 'carUsers.user.id', 'carUsers.user.name', 'carUsers.user.firstName', 'carUsers.owner', 'carUsers.default'
]
},
{
@@ -326,7 +328,9 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
resource: Entity.CARS, action: Action.LIST, attributes: [
'id', 'type', 'vin', 'licensePlate', 'converter', 'default', 'owner', 'createdOn', 'lastChangedOn',
'carCatalog.id', 'carCatalog.vehicleMake', 'carCatalog.vehicleModel', 'carCatalog.vehicleModelVersion',
- 'carCatalog.image', 'carCatalog.fastChargePowerMax', 'carCatalog.batteryCapacityFull'
+ 'carCatalog.image', 'carCatalog.fastChargePowerMax', 'carCatalog.batteryCapacityFull',
+ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName',
+ 'carUsers.user.id', 'carUsers.user.name', 'carUsers.user.firstName', 'carUsers.owner', 'carUsers.default'
], condition: {
Fn: 'custom:dynamicAuthorizationFilters',
args: { filters: ['OwnUser'] }

MODIFY
src/server/ocpp/utils/OCPPUtils.ts
src/server/ocpp/utils/OCPPUtils.ts
@@ -834,8 +834,7 @@ export default class OCPPUtils {
// Meter Value Handling
if (OCPPUtils.isValidMeterValue(meterValue)) {
// Meter Value is in the past
- if (transaction?.lastConsumption?.timestamp &&
- meterValue?.timestamp &&
+ if (transaction.lastConsumption?.timestamp && meterValue.timestamp &&
moment(meterValue?.timestamp).isBefore(moment(transaction?.lastConsumption?.timestamp))) {
await Logging.logError({
tenantID: tenant.id,

MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -506,7 +506,6 @@ export default class AuthorizationService {
authorizationFilter: AuthorizationFilter, filteredRequest: HttpSiteAreasRequest): Promise<void> {
// Add canCreate flag to root
siteAreas.canCreate = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE_AREA, Action.CREATE, authorizationFilter);
-
// Enrich
for (const siteArea of siteAreas.result) {
await AuthorizationService.addSiteAreaAuthorizations(tenant, userToken, siteArea, authorizationFilter, filteredRequest);

MODIFY
src/server/rest/v1/service/CarService.ts
src/server/rest/v1/service/CarService.ts
@@ -81,14 +81,9 @@ export default class CarService {
}
public static async handleGetCarCatalogImage(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
- if (!Authorizations.isSuperAdmin(req.user)) {
- // Check if component is active
- UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.CAR, Action.DELETE, Entity.CAR_CATALOG,
- MODULE_NAME, 'handleGetCarCatalogImage');
- }
+ // Unprotected Endpoint: No JWT token is provided
// Filter
const filteredRequest = CarSecurity.filterCarCatalogRequest(req.query);
- // Check mandatory fields
UtilsService.assertIdIsProvided(action, filteredRequest.ID, MODULE_NAME, 'handleGetCarCatalogImage', req.user);
// Get the car Image
const carCatalog = await CarStorage.getCarCatalogImage(filteredRequest.ID);
@@ -407,13 +402,6 @@ export default class CarService {
UtilsService.sendEmptyDataResult(res, next);
return;
}
- // Check User
- let userProject: string[] = [];
- if ((await Authorizations.canListUsers(req.user)).authorized) {
- userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName',
- 'carUsers.user.id', 'carUsers.user.name', 'carUsers.user.firstName', 'carUsers.owner', 'carUsers.default' ];
- authorizationCarsFilter.projectFields = authorizationCarsFilter.projectFields.concat(userProject);
- }
// Get cars
const cars = await CarStorage.getCars(req.user.tenantID,
{

Fixed auth refactoring issues