Small fix tu support both add & remove actions.
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -229,9 +229,18 @@ export default class AuthorizationService {
const assetIDs = await AuthorizationService.getAssignedAssetIDs(tenant.id, siteArea.siteID);
// Check if any of the Assets we want to unassign are missing
for (const assetID of filteredRequest.assetIDs) {
+ switch (action) {
+ case ServerAction.ADD_CHARGING_STATIONS_TO_SITE_AREA:
+ if (assetIDs.includes(assetID)) {
+ foundInvalidAssetID = true;
+ }
+ break;
+ case ServerAction.REMOVE_CHARGING_STATIONS_FROM_SITE_AREA:
if (!assetIDs.includes(assetID)) {
foundInvalidAssetID = true;
}
+ break;
+ }
}
if (!foundInvalidAssetID) {
authorizationFilters.authorized = true;
@@ -263,9 +272,18 @@ export default class AuthorizationService {
const chargingStationIDs = await AuthorizationService.getAssignedChargingStationIDs(tenant.id, siteArea.siteID);
// Check if any of the Charging Stations we want to unassign are missing
for (const chargingStationID of filteredRequest.chargingStationIDs) {
+ switch (action) {
+ case ServerAction.ADD_CHARGING_STATIONS_TO_SITE_AREA:
+ if (chargingStationIDs.includes(chargingStationID)) {
+ foundInvalidChargingStationID = true;
+ }
+ break;
+ case ServerAction.REMOVE_CHARGING_STATIONS_FROM_SITE_AREA:
if (!chargingStationIDs.includes(chargingStationID)) {
foundInvalidChargingStationID = true;
}
+ break;
+ }
}
if (!foundInvalidChargingStationID) {
authorizationFilters.authorized = true;

Small fix tu support both add & remove actions.