Fixed missing await
MODIFY
src/server/rest/v1/service/SiteAreaService.ts
src/server/rest/v1/service/SiteAreaService.ts
@@ -35,7 +35,7 @@ export default class SiteAreaService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ASSET,
Action.UPDATE, Entity.ASSET, MODULE_NAME, 'handleAssignAssetsToSiteArea');
// Check static auth
- if (!Authorizations.canUpdateSiteArea(req.user)) {
+ if (!await Authorizations.canUpdateSiteArea(req.user)) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -101,7 +101,7 @@ export default class SiteAreaService {
req.user, TenantComponents.ORGANIZATION,
Action.UPDATE, Entity.CHARGING_STATION, MODULE_NAME, 'handleAssignChargingStationsToSiteArea');
// Check static auth
- if (!Authorizations.canUpdateSiteArea(req.user)) {
+ if (!await Authorizations.canUpdateSiteArea(req.user)) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -192,7 +192,7 @@ export default class SiteAreaService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ORGANIZATION,
Action.DELETE, Entity.SITE_AREA, MODULE_NAME, 'handleDeleteSiteArea');
// Check static auth
- if (!Authorizations.canDeleteSiteArea(req.user)) {
+ if (!await Authorizations.canDeleteSiteArea(req.user)) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -383,7 +383,7 @@ export default class SiteAreaService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ORGANIZATION,
Action.CREATE, Entity.SITE_AREAS, MODULE_NAME, 'handleCreateSiteArea');
// Check static auth
- if (!Authorizations.canCreateSiteArea(req.user)) {
+ if (!await Authorizations.canCreateSiteArea(req.user)) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -424,7 +424,7 @@ export default class SiteAreaService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ORGANIZATION,
Action.UPDATE, Entity.SITE_AREA, MODULE_NAME, 'handleUpdateSiteArea');
// Check static auth
- if (!Authorizations.canUpdateSiteArea(req.user)) {
+ if (!await Authorizations.canUpdateSiteArea(req.user)) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,

MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -235,7 +235,7 @@ export default class TagService {
// Filter
const filteredRequest = TagSecurity.filterTagCreateRequest(req.body, req.user);
// Check
- await UtilsService.checkIfUserTagIsValid(filteredRequest, req);
+ UtilsService.checkIfUserTagIsValid(filteredRequest, req);
// Check Tag
const tag = await TagStorage.getTag(req.user.tenantID, filteredRequest.id.toUpperCase());
if (tag) {
@@ -345,7 +345,7 @@ export default class TagService {
let formerTagUserID: string;
let formerTagDefault: boolean;
// Check
- await UtilsService.checkIfUserTagIsValid(filteredRequest, req);
+ UtilsService.checkIfUserTagIsValid(filteredRequest, req);
// Get Tag
const tag = await TagStorage.getTag(req.user.tenantID, filteredRequest.id, { withNbrTransactions: true, withUser: true });
UtilsService.assertObjectExists(action, tag, `Tag ID '${filteredRequest.id}' does not exist`,

MODIFY
src/server/rest/v1/service/UtilsService.ts
src/server/rest/v1/service/UtilsService.ts
@@ -43,7 +43,7 @@ export default class UtilsService {
public static async checkAndGetChargingStationAuthorization(tenant: Tenant, userToken: UserToken, chargingStationID: string,
method: string, action: ServerAction, additionalFilters: Record<string, any>, applyProjectFields = false): Promise<ChargingStation> {
// Check static auth for reading Charging Station
- if (!Authorizations.canReadChargingStation(userToken)) {
+ if (!await Authorizations.canReadChargingStation(userToken)) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: userToken,
@@ -103,7 +103,7 @@ export default class UtilsService {
public static async checkAndGetCompanyAuthorization(tenant: Tenant, userToken: UserToken, companyID: string,
method: string, action: ServerAction, additionalFilters: Record<string, any>, applyProjectFields = false): Promise<Company> {
// Check static auth for reading company
- if (!Authorizations.canReadCompany(userToken)) {
+ if (!await Authorizations.canReadCompany(userToken)) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: userToken,
@@ -152,7 +152,7 @@ export default class UtilsService {
public static async checkAndGetUserAuthorization(tenant: Tenant, userToken: UserToken, userID: string,
method: string, action: ServerAction, additionalFilters: Record<string, any>, applyProjectFields = false): Promise<User> {
// Check static auth for reading user
- if (!Authorizations.canReadUser(userToken, userID)) {
+ if (!await Authorizations.canReadUser(userToken, userID)) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: userToken,
@@ -201,7 +201,7 @@ export default class UtilsService {
public static async checkAndGetSiteAuthorization(tenant: Tenant, userToken: UserToken, siteID: string,
method: string, action: ServerAction, additionalFilters: Record<string, any>, applyProjectFields = false): Promise<Site> {
// Check static auth for reading site
- if (!Authorizations.canReadSite(userToken)) {
+ if (!await Authorizations.canReadSite(userToken)) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: userToken,
@@ -250,7 +250,7 @@ export default class UtilsService {
public static async checkAndGetSiteAreaAuthorization(tenant: Tenant, userToken: UserToken, siteAreaID: string,
method: string, action: ServerAction, additionalFilters: Record<string, any>, applyProjectFields = false): Promise<SiteArea> {
// Check static auth for reading site area
- if (!Authorizations.canReadSiteArea(userToken)) {
+ if (!await Authorizations.canReadSiteArea(userToken)) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: userToken,
@@ -885,7 +885,7 @@ export default class UtilsService {
throw new AppError({
source: Constants.CENTRAL_SERVER,
errorCode: HTTPError.GENERAL_ERROR,
- message: `Site voltage must be either 110V or 230V but got ${siteArea.voltage} kW`,
+ message: `Site voltage must be either 110V or 230V but got ${siteArea.voltage as number}V`,
module: MODULE_NAME, method: 'checkIfSiteAreaValid',
user: req.user.id
});
@@ -1001,7 +1001,7 @@ export default class UtilsService {
}
}
- public static async checkIfUserTagIsValid(tag: Partial<Tag>, req: Request): Promise<void> {
+ public static checkIfUserTagIsValid(tag: Partial<Tag>, req: Request): void {
// Check badge ID
if (!tag.id) {
throw new AppError({

Fixed missing await