merge with master-qa
MODIFY
src/authorization/Authorizations.ts
src/authorization/Authorizations.ts
@@ -296,9 +296,8 @@ export default class Authorizations {
return Authorizations.canPerformAction(loggedUser, Entity.TAGS, Action.LIST);
}
- public static canReadTag(loggedUser: UserToken, userId: string): boolean {
- return Authorizations.canPerformAction(loggedUser, Entity.TAG, Action.READ,
- { user: userId, owner: loggedUser.id });
+ public static canReadTag(loggedUser: UserToken): boolean {
+ return Authorizations.canPerformAction(loggedUser, Entity.TAG, Action.READ);
}
public static canDeleteTag(loggedUser: UserToken): boolean {

MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -158,9 +158,9 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
}
},
{
- resource: Entity.TAG, action: Action.READ, attributes: ['*'],
- condition: { Fn: 'EQUALS', args: { 'user': '$.owner' } }
+ resource: Entity.TAG, action: Action.READ, attributes: ['*']
},
+ { resource: Entity.TAGS, action: Action.LIST, attributes: ['*'] },
{
resource: Entity.CHARGING_STATION,
action: [Action.REMOTE_STOP_TRANSACTION, Action.STOP_TRANSACTION],

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -457,7 +457,8 @@ export default class TransactionService {
'stop.userID', 'stop.user.id', 'stop.user.name', 'stop.user.firstName', 'stop.user.email',
'currentTotalDurationSecs', 'currentTotalInactivitySecs', 'currentInstantWatts', 'currentTotalConsumptionWh', 'currentStateOfCharge',
'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.pricingSource', 'stop.roundedPrice', 'stop.tagID'
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.pricingSource', 'stop.roundedPrice', 'stop.tagID','car.licensePlate',
+ 'car.carCatalog.vehicleMake','car.carCatalog.vehicleModel','car.carCatalog.vehicleModelVersion','car.carCatalog.image'
]);
UtilsService.assertObjectExists(action, transaction, `Transaction with ID '${filteredRequest.TransactionId}' does not exist`,
MODULE_NAME, 'handleGetConsumptionFromTransaction', req.user);
@@ -610,7 +611,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', 'car.licensePlate', 'car.carCatalog.vehicleMake','car.carCatalog.vehicleModel','car.carCatalog.vehicleModelVersion'
]);
res.json(transactions);
next();
@@ -621,7 +622,8 @@ 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',
+ 'car.licensePlate', 'car.carCatalog.vehicleMake','car.carCatalog.vehicleModel','car.carCatalog.vehicleModelVersion'
]);
res.json(transactions);
next();

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -1015,7 +1015,7 @@ export default class UserService {
public static async handleGetTag(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
const tagID = UserSecurity.filterTagRequestByID(req.query);
// Check auth
- if (!Authorizations.canReadTag(req.user, tagID)) {
+ if (!Authorizations.canReadTag(req.user)) {
throw new AppAuthError({
errorCode: HTTPAuthError.ERROR,
user: req.user,
@@ -1044,9 +1044,9 @@ export default class UserService {
}
public static async handleGetUserDefaultTagCar(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
- const userID = UserSecurity.filterDefaultTagCarRequestByUserID(req.query);
+ let userID = UserSecurity.filterDefaultTagCarRequestByUserID(req.query);
// Check auth
- if (!Authorizations.canReadTag(req.user, userID)) {
+ if (!Authorizations.canReadTag(req.user)) {
throw new AppAuthError({
errorCode: HTTPAuthError.ERROR,
user: req.user,
@@ -1064,6 +1064,9 @@ export default class UserService {
});
}
UtilsService.assertIdIsProvided(action, userID, MODULE_NAME, 'handleGetUserDefaultTagCar', req.user);
+ if (Authorizations.isBasic(req.user)) {
+ userID = req.user.id;
+ }
// Get the tag
let tagsMDB = await UserStorage.getTags(req.user.tenantID, {
userIDs: [userID],
@@ -1119,11 +1122,17 @@ export default class UserService {
}
// Filter
const filteredRequest = UserSecurity.filterTagsRequest(req.query);
+ let userID: string;
+ if (Authorizations.isBasic(req.user)) {
+ userID = req.user.id;
+ } else {
+ userID = filteredRequest.UserID;
+ }
// Get the tags
const tags = await UserStorage.getTags(req.user.tenantID,
{
search: filteredRequest.Search,
- userIDs: filteredRequest.UserID ? filteredRequest.UserID.split('|') : null,
+ userIDs: [userID],
issuer: filteredRequest.Issuer,
active: filteredRequest.Active,
withUser: true,

MODIFY
src/types/User.ts
src/types/User.ts
import Address from './Address';
import { BillingUserData } from './Billing';
-import { Car } from './Car';
import CreatedUpdatedProps from './CreatedUpdatedProps';
import UserNotifications from './UserNotifications';
@@ -46,11 +45,6 @@ export interface UserSite {
siteOwner: boolean;
}
-export interface UserDefaultTagCar {
- car?: Car;
- tag?: Tag;
-}
-
export interface UserCar extends CreatedUpdatedProps {
id?: string;
user: User;

merge with master-qa