Added canReadUsers for Admin/Site Admin in Site list for OCPI
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -373,7 +373,17 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'user.id', 'user.name', 'user.firstName', 'user.email', 'user.role', 'siteAdmin', 'siteOwner', 'siteID'
]
},
- { resource: Entity.USERS_SITES, action: [Action.ASSIGN, Action.UNASSIGN] },
+ {
+ resource: Entity.USERS_SITES,
+ action: [Action.ASSIGN, Action.UNASSIGN, Action.READ],
+ condition: {
+ Fn: 'custom:dynamicAuthorizations',
+ args: {
+ asserts: [],
+ filters: ['LocalIssuer']
+ }
+ },
+ },
{ resource: Entity.PAYMENT_METHOD, action: Action.LIST },
{ resource: Entity.PAYMENT_METHOD, action: [Action.READ, Action.CREATE, Action.DELETE] },
]
@@ -941,6 +951,17 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'user.id', 'user.name', 'user.firstName', 'user.email', 'user.role', 'siteAdmin', 'siteOwner', 'siteID'
]
},
+ {
+ resource: Entity.USERS_SITES,
+ action: Action.READ,
+ condition: {
+ Fn: 'custom:dynamicAuthorizations',
+ args: {
+ asserts: [],
+ filters: ['LocalIssuer']
+ }
+ },
+ },
{
resource: Entity.SITE, action: [Action.UPDATE],
condition: {

MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -110,6 +110,9 @@ export default class AuthorizationService {
site.canUnassignUsers = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.USERS_SITES, Action.UNASSIGN, authorizationFilter, { SiteID: site.id }, site);
!site.canUnassignUsers && delete site.canUnassignUsers; // Optimize data over the net
+ site.canReadUsers = await AuthorizationService.canPerformAuthorizationAction(
+ tenant, userToken, Entity.USERS_SITES, Action.READ, authorizationFilter, { SiteID: site.id }, site);
+ !site.canReadUsers && delete site.canReadUsers; // Optimize data over the net
}
}

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

Added canReadUsers for Admin/Site Admin in Site list for OCPI