Updated projected fields
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -80,6 +80,10 @@ export default class AuthorizationService {
}
public static async addSiteAuthorizations(tenant: Tenant, userToken: UserToken, site: Site, authorizationFilter: AuthorizationFilter): Promise<void> {
+ // Assign projected fields
+ if (authorizationFilter.projectFields) {
+ site.projectedFields = authorizationFilter.projectFields;
+ }
// Enrich
if (!site.issuer) {
site.canRead = true;
@@ -103,10 +107,6 @@ export default class AuthorizationService {
site.canUnassignUsers = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.USERS_SITES, Action.UNASSIGN, authorizationFilter, { SiteID: site.id }, site);
}
- // Assign projected fields
- if (authorizationFilter.projectFields) {
- site.projectedFields = authorizationFilter.projectFields;
- }
}
public static async checkAndGetSitesAuthorizations(tenant: Tenant, userToken: UserToken,
@@ -251,6 +251,10 @@ export default class AuthorizationService {
}
public static async addUserAuthorizations(tenant: Tenant, userToken: UserToken, user: User, authorizationFilter: AuthorizationFilter): Promise<void> {
+ // Assign projected fields
+ if (authorizationFilter.projectFields) {
+ user.projectedFields = authorizationFilter.projectFields;
+ }
// Enrich
if (!user.issuer) {
user.canRead = true;
@@ -264,10 +268,6 @@ export default class AuthorizationService {
user.canDelete = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.USER, Action.DELETE, authorizationFilter, { UserID: user.id }, user);
}
- // Assign projected fields
- if (authorizationFilter.projectFields) {
- user.projectedFields = authorizationFilter.projectFields;
- }
}
public static async checkAndGetUsersAuthorizations(tenant: Tenant, userToken: UserToken,
@@ -339,6 +339,10 @@ export default class AuthorizationService {
}
public static async addTagAuthorizations(tenant: Tenant, userToken: UserToken, tag: Tag, authorizationFilter: AuthorizationFilter): Promise<void> {
+ // Assign projected fields
+ if (authorizationFilter.projectFields) {
+ tag.projectedFields = authorizationFilter.projectFields;
+ }
// Enrich
if (!tag.issuer) {
tag.canRead = true;
@@ -358,10 +362,6 @@ export default class AuthorizationService {
tag.canAssign = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.TAG, Action.ASSIGN, authorizationFilter, { TagID: tag.id }, tag);
}
- // Assign projected fields
- if (authorizationFilter.projectFields) {
- tag.projectedFields = authorizationFilter.projectFields;
- }
}
public static async checkAndGetCompaniesAuthorizations(tenant: Tenant, userToken: UserToken,
@@ -389,6 +389,10 @@ export default class AuthorizationService {
}
public static async addCompanyAuthorizations(tenant: Tenant, userToken: UserToken, company: Company, authorizationFilter: AuthorizationFilter): Promise<void> {
+ // Assign projected fields
+ if (authorizationFilter.projectFields) {
+ company.projectedFields = authorizationFilter.projectFields;
+ }
// Enrich
if (!company.issuer) {
company.canRead = true;
@@ -402,10 +406,6 @@ export default class AuthorizationService {
company.canUpdate = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.COMPANY, Action.UPDATE, authorizationFilter, { CompanyID: company.id }, company);
}
- // Assign projected fields
- if (authorizationFilter.projectFields) {
- company.projectedFields = authorizationFilter.projectFields;
- }
}
public static async checkAndGetCompanyAuthorizations(tenant: Tenant, userToken: UserToken,
@@ -445,6 +445,10 @@ export default class AuthorizationService {
}
public static async addSiteAreaAuthorizations(tenant: Tenant, userToken: UserToken, siteArea: SiteArea, authorizationFilter: AuthorizationFilter): Promise<void> {
+ // Assign projected fields
+ if (authorizationFilter.projectFields) {
+ siteArea.projectedFields = authorizationFilter.projectFields;
+ }
// Enrich
if (!siteArea.issuer) {
siteArea.canRead = true;
@@ -475,10 +479,6 @@ export default class AuthorizationService {
siteArea.canGenerateQrCode = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.SITE_AREA, Action.GENERATE_QR, authorizationFilter, { SiteAreaID: siteArea.id, SiteID: siteArea.siteID }, siteArea);
}
- // Assign projected fields
- if (authorizationFilter.projectFields) {
- siteArea.projectedFields = authorizationFilter.projectFields;
- }
}
public static async checkAndGetChargingStationAuthorizations(tenant: Tenant, userToken: UserToken,
@@ -537,6 +537,10 @@ export default class AuthorizationService {
}
public static async addCarAuthorizations(tenant: Tenant, userToken: UserToken, car: Car, authorizationFilter: AuthorizationFilter): Promise<void> {
+ // Assign projected fields
+ if (authorizationFilter.projectFields) {
+ car.projectedFields = authorizationFilter.projectFields;
+ }
// Enrich
car.canRead = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.CAR, Action.READ, authorizationFilter, { CarID: car.id }, car);
@@ -544,10 +548,6 @@ export default class AuthorizationService {
tenant, userToken, Entity.CAR, Action.DELETE, authorizationFilter, { CarID: car.id }, car);
car.canUpdate = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.CAR, Action.UPDATE, authorizationFilter, { CarID: car.id }, car);
- // Assign projected fields
- if (authorizationFilter.projectFields) {
- car.projectedFields = authorizationFilter.projectFields;
- }
}
public static async checkAndGetCarCatalogsAuthorizations(tenant: Tenant, userToken: UserToken,
@@ -581,6 +581,10 @@ export default class AuthorizationService {
}
public static async addCarCatalogAuthorizations(tenant: Tenant, userToken: UserToken, carCatalog: CarCatalog, authorizationFilter: AuthorizationFilter): Promise<void> {
+ // Assign projected fields
+ if (authorizationFilter.projectFields) {
+ carCatalog.projectedFields = authorizationFilter.projectFields;
+ }
// Enrich
carCatalog.canRead = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.CAR_CATALOG, Action.READ, authorizationFilter, { CarCatalogID: carCatalog.id }, carCatalog);
@@ -588,10 +592,6 @@ export default class AuthorizationService {
tenant, userToken, Entity.CAR_CATALOG, Action.DELETE, authorizationFilter, { CarCatalogID: carCatalog.id }, carCatalog);
carCatalog.canUpdate = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.CAR_CATALOG, Action.UPDATE, authorizationFilter, { CarCatalogID: carCatalog.id }, carCatalog);
- // Assign projected fields
- if (authorizationFilter.projectFields) {
- carCatalog.projectedFields = authorizationFilter.projectFields;
- }
}

Updated projected fields