Add flags for site
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -67,7 +67,10 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'autoUserSiteAssignment', 'distanceMeters', 'public', 'createdOn', 'lastChangedOn'
]
},
- { resource: Entity.SITE, action: [Action.CREATE, Action.UPDATE, Action.DELETE], attributes: ['*'] },
+ {
+ resource: Entity.SITE, action: [Action.CREATE, Action.UPDATE, Action.DELETE,
+ Action.EXPORT_OCPP_PARAMS, Action.GENERATE_QR], attributes: ['*']
+ },
{
resource: Entity.SITE_AREAS, action: Action.LIST, attributes: [
'id', 'name', 'siteID', 'maximumPower', 'voltage', 'numberOfPhases', 'accessControl', 'smartCharging', 'address',
@@ -80,9 +83,11 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'voltage', 'smartCharging', 'accessControl', 'connectorStats', 'siteID', 'site.name'
]
},
- { resource: Entity.SITE_AREA, action: [Action.CREATE, Action.UPDATE, Action.DELETE,
+ {
+ 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,
- Action.EXPORT_OCPP_PARAMS, Action.GENERATE_QR], attributes: ['*'] },
+ Action.EXPORT_OCPP_PARAMS, Action.GENERATE_QR], attributes: ['*']
+ },
{
resource: Entity.CHARGING_STATIONS, action: [Action.LIST, Action.IN_ERROR],
attributes: [

MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -108,9 +108,16 @@ export default class AuthorizationService {
site.canUnassignUsers = false;
} else {
filteredRequest.SiteID = site.id;
- site.canRead = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE, Action.READ, authorizationFilter, filteredRequest);
- site.canDelete = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE, Action.DELETE, authorizationFilter, filteredRequest);
- site.canUpdate = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE, Action.UPDATE, authorizationFilter, filteredRequest);
+ site.canRead = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE, Action.READ,
+ authorizationFilter, filteredRequest);
+ site.canDelete = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE, Action.DELETE,
+ authorizationFilter, filteredRequest);
+ site.canUpdate = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE, Action.UPDATE,
+ authorizationFilter, filteredRequest);
+ site.canExportOCPPParams = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE_AREA, Action.EXPORT_OCPP_PARAMS,
+ authorizationFilter, filteredRequest);
+ site.canGenerateQrCode = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE_AREA, Action.GENERATE_QR,
+ authorizationFilter, filteredRequest);
site.canAssignUsers = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.USERS_SITES, Action.ASSIGN,
authorizationFilter, filteredRequest);
site.canUnassignUsers = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.USERS_SITES, Action.UNASSIGN,

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -192,6 +192,8 @@ export interface SiteAreaAuthorizationActions extends AuthorizationActions {
export interface SiteAuthorizationActions extends AuthorizationActions {
canAssignUsers?: boolean;
canUnassignUsers?: boolean;
+ canExportOCPPParams?: boolean;
+ canGenerateQrCode?:boolean;
}
export enum DynamicAuthorizationFilterName {

Add flags for site