Add ASSIGN / UNASSIGN actions.
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -56,7 +56,8 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'voltage', 'smartCharging', 'accessControl', 'connectorStats', 'siteID', 'site.name'
]
},
- { resource: Entity.SITE_AREA, action: [Action.CREATE, Action.UPDATE, Action.DELETE], attributes: ['*'] },
+ { resource: Entity.SITE_AREA, action: [Action.CREATE, Action.UPDATE, Action.DELETE,
+ Action.ASSIGN_ASSETS, Action.UNASSIGN_ASSETS, Action.ASSIGN_CHARGING_STATIONS, Action.UNASSIGN_CHARGING_STATIONS], attributes: ['*'] },
{ resource: Entity.CHARGING_STATIONS, action: [Action.LIST, Action.IN_ERROR], attributes: ['*'] },
{
resource: Entity.CHARGING_STATION, action: [Action.CREATE, Action.READ, Action.UPDATE, Action.DELETE,
@@ -326,7 +327,8 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
{ resource: Entity.USERS_SITES, action: Action.LIST, attributes: ['*'] },
{ resource: Entity.USERS_SITES, action: [Action.UNASSIGN], attributes: ['*'] },
{ resource: Entity.SITE, action: [Action.UPDATE], attributes: ['*'] },
- { resource: Entity.SITE_AREA, action: [Action.CREATE, Action.UPDATE, Action.DELETE], attributes: ['*'],
+ { resource: Entity.SITE_AREA, action: [Action.CREATE, Action.UPDATE, Action.DELETE,
+ Action.ASSIGN_ASSETS, Action.UNASSIGN_ASSETS, Action.ASSIGN_CHARGING_STATIONS, Action.UNASSIGN_CHARGING_STATIONS], attributes: ['*'],
condition: {
Fn: 'custom:dynamicAuthorizationFilters',
args: { filters: ['SitesAdmin'] }

MODIFY
src/server/rest/v1/service/SiteAreaService.ts
src/server/rest/v1/service/SiteAreaService.ts
@@ -72,8 +72,7 @@ export default class SiteAreaService {
public static async handleAssignChargingStationsToSiteArea(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Check if component is active
- UtilsService.assertComponentIsActiveFromToken(
- req.user, TenantComponents.ORGANIZATION,
+ UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ORGANIZATION,
Action.UPDATE, Entity.CHARGING_STATION, MODULE_NAME, 'handleAssignChargingStationsToSiteArea');
// Filter request
const filteredRequest = SiteAreaSecurity.filterAssignChargingStationsToSiteAreaRequest(req.body);

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -148,7 +148,11 @@ export enum Action {
REGISTER = 'Register',
TRIGGER_JOB = 'TriggerJob',
DOWNLOAD = 'Download',
- IMPORT = 'Import'
+ IMPORT = 'Import',
+ ASSIGN_ASSETS = 'AssignAssets',
+ UNASSIGN_ASSETS = 'UnassignAssets',
+ ASSIGN_CHARGING_STATIONS = 'AssignChargingStations',
+ UNASSIGN_CHARGING_STATIONS = 'UnassignChargingStations'
}
export interface AuthorizationContext {

Add ASSIGN / UNASSIGN actions.