Fix missing tgs in sessions
MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -476,16 +476,10 @@ export default class TransactionService {
// Remove User
delete transaction.user;
delete transaction.userID;
+ delete transaction.tagID;
if (transaction.stop) {
delete transaction.stop.user;
delete transaction.stop.userID;
- }
- }
- // Check Tags
- if (!Authorizations.canReadTag(req.user)) {
- // Remove Tag
- delete transaction.tagID;
- if (transaction.stop) {
delete transaction.stop.tagID;
}
}
@@ -563,16 +557,10 @@ export default class TransactionService {
// Remove User
delete transaction.user;
delete transaction.userID;
+ delete transaction.tagID;
if (transaction.stop) {
delete transaction.stop.user;
delete transaction.stop.userID;
- }
- }
- // Check Tags
- if (!Authorizations.canReadTag(req.user)) {
- // Remove Tag
- delete transaction.tagID;
- if (transaction.stop) {
delete transaction.stop.tagID;
}
}
@@ -587,7 +575,7 @@ export default class TransactionService {
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID',
'currentTotalDurationSecs', 'currentTotalInactivitySecs', 'currentInstantWatts', 'currentTotalConsumptionWh', 'currentStateOfCharge',
'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'billingData.invoiceID', 'ocpiWithNoCdr'
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'billingData.invoiceID', 'ocpiWithNoCdr', 'tagID', 'stop.tagID',
]);
res.json(transactions);
next();
@@ -610,7 +598,7 @@ export default class TransactionService {
const transactions = await TransactionService.getTransactions(req, action, { completedTransactions: false }, [
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'status', 'meterStart', 'siteAreaID', 'siteID',
'currentTotalDurationSecs', 'currentTotalInactivitySecs', 'currentInstantWatts', 'currentTotalConsumptionWh', 'currentStateOfCharge',
- 'currentCumulatedPrice', 'currentInactivityStatus', 'price', 'roundedPrice'
+ 'currentCumulatedPrice', 'currentInactivityStatus', 'price', 'roundedPrice', 'tagID', 'stop.tagID',
]);
res.json(transactions);
next();
@@ -621,7 +609,7 @@ export default class TransactionService {
const transactions = await TransactionService.getTransactions(req, action, { completedTransactions: true }, [
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID',
'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.meterStop', 'billingData.invoiceID', 'ocpiWithNoCdr'
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.meterStop', 'billingData.invoiceID', 'ocpiWithNoCdr', 'tagID', 'stop.tagID',
]);
res.json(transactions);
next();
@@ -638,7 +626,7 @@ export default class TransactionService {
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID',
'refundData.reportId', 'refundData.refundedAt', 'refundData.status', 'siteID',
'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'billingData.invoiceID'
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'billingData.invoiceID', 'tagID', 'stop.tagID',
]);
res.json(transactions);
next();
@@ -660,12 +648,7 @@ export default class TransactionService {
// Check Users
let userProject: string[] = [];
if (Authorizations.canListUsers(req.user)) {
- userProject = [ 'userID', 'user.id', 'user.name', 'user.firstName', 'user.email' ];
- }
- // Check Tags
- let tagProject: string[] = [];
- if (Authorizations.canListTags(req.user)) {
- tagProject = [ 'tagID' ];
+ userProject = [ 'userID', 'user.id', 'user.name', 'user.firstName', 'user.email', 'tagID' ];
}
const filter: any = { stop: { $exists: true } };
// Filter
@@ -689,7 +672,7 @@ export default class TransactionService {
sort: filteredRequest.Sort,
onlyRecordCount: filteredRequest.OnlyRecordCount
},
- [ 'id', ...userProject, ...tagProject ]);
+ [ 'id', ...userProject ]);
// Return
res.json(reports);
next();
@@ -706,7 +689,7 @@ export default class TransactionService {
return TransactionService.getTransactions(req, ServerAction.TRANSACTIONS_EXPORT, { completedTransactions: true }, [
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID',
'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'billingData.invoiceID', 'ocpiWithNoCdr'
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'billingData.invoiceID', 'ocpiWithNoCdr', 'tagID', 'stop.tagID',
]);
}
@@ -721,7 +704,7 @@ export default class TransactionService {
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID',
'refundData.reportId', 'refundData.refundedAt', 'refundData.status', 'siteID',
'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'billingData.invoiceID'
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'billingData.invoiceID', 'tagID', 'stop.tagID',
]);
}
@@ -912,16 +895,7 @@ export default class TransactionService {
projectFields = [
...projectFields,
'userID', 'user.id', 'user.name', 'user.firstName', 'user.email',
- 'stop.userID', 'stop.user.id', 'stop.user.name', 'stop.user.firstName', 'stop.user.email',
- ];
- }
- }
- // Check Tags
- if (Authorizations.canListTags(req.user)) {
- if (projectFields) {
- projectFields = [
- ...projectFields,
- 'tagID', 'stop.tagID'
+ 'stop.userID', 'stop.user.id', 'stop.user.name', 'stop.user.firstName', 'stop.user.email'
];
}
}

MODIFY
src/server/rest/v1/service/UtilsService.ts
src/server/rest/v1/service/UtilsService.ts
@@ -716,7 +716,7 @@ export default class UtilsService {
throw new AppError({
source: Constants.CENTRAL_SERVER,
errorCode: HTTPError.GENERAL_ERROR,
- message: 'Car Vin is mandatory',
+ message: 'Vin Car is mandatory',
module: MODULE_NAME, method: 'checkIfCarValid',
user: req.user.id
});

MODIFY
test/api/TransactionCommonTests.ts
test/api/TransactionCommonTests.ts
@@ -6,7 +6,6 @@ import ChargingStationContext from './context/ChargingStationContext';
import TenantContext from './context/TenantContext';
import TestUtils from './TestUtils';
import { TransactionInErrorType } from '../../src/types/InError';
-import User from '../../src/types/User';
import Utils from '../../src/utils/Utils';
import chaiSubset from 'chai-subset';
import faker from 'faker';

Fix missing tgs in sessions