Added user to charging station service
MODIFY
src/server/rest/service/security/ChargingStationSecurity.ts
src/server/rest/service/security/ChargingStationSecurity.ts
@@ -9,6 +9,7 @@ import { DataResult } from '../../../../types/DataResult';
import HttpByIDRequest from '../../../../types/requests/HttpByIDRequest';
import HttpDatabaseRequest from '../../../../types/requests/HttpDatabaseRequest';
import { InactivityStatus } from '../../../../types/Transaction';
+import UserSecurity from './UserSecurity';
import UserToken from '../../../../types/UserToken';
import Utils from '../../../../utils/Utils';
import UtilsSecurity from './UtilsSecurity';
@@ -48,7 +49,9 @@ export default class ChargingStationSecurity {
// Yes: set all params
filteredChargingStation = chargingStation;
for (const connector of filteredChargingStation.connectors) {
- if (connector && filteredChargingStation.inactive) {
+ if (connector) {
+ // Inactive
+ if (filteredChargingStation.inactive) {
connector.status = ChargePointStatus.UNAVAILABLE;
connector.currentConsumption = 0;
connector.totalConsumption = 0;
@@ -56,6 +59,11 @@ export default class ChargingStationSecurity {
connector.inactivityStatus = InactivityStatus.INFO;
connector.currentStateOfCharge = 0;
}
+ // Filter User
+ if (connector.user) {
+ connector.user = UserSecurity.filterMinimalUserResponse(connector.user, loggedUser);
+ }
+ }
}
} else {
// Set only necessary info
@@ -84,7 +92,8 @@ export default class ChargingStationSecurity {
numberOfConnectedPhase: connector.numberOfConnectedPhase,
currentType: connector.currentType,
voltage: connector.voltage,
- amperage: connector.amperage
+ amperage: connector.amperage,
+ user: UserSecurity.filterMinimalUserResponse(connector.user, loggedUser)
};
});
if (chargingStation.chargePoints) {

MODIFY
src/server/rest/service/security/UserSecurity.ts
src/server/rest/service/security/UserSecurity.ts
@@ -221,8 +221,8 @@ export default class UserSecurity {
}
// User
- static filterMinimalUserResponse(user: User, loggedUser: UserToken): void {
- const filteredUser: any = {};
+ static filterMinimalUserResponse(user: User, loggedUser: UserToken): User {
+ const filteredUser = {} as User;
if (!user) {
return null;
}

MODIFY
src/types/ChargingStation.ts
src/types/ChargingStation.ts
@@ -6,6 +6,7 @@ import { InactivityStatus } from './Transaction';
import { KeyValue } from './GlobalType';
import { OCPIEvse } from './ocpi/OCPIEvse';
import SiteArea from './SiteArea';
+import User from './User';
export default interface ChargingStation extends CreatedUpdatedProps {
id?: string;
@@ -104,6 +105,7 @@ export interface Connector {
amperageLimit?: number;
activeTransactionID?: number;
userID?: string;
+ user?: User;
activeTransactionDate?: Date;
activeTagID?: string;
statusLastChangedOn?: Date;

Added user to charging station service