Updated Asset + Invoice auths
MODIFY
src/authorization/Authorizations.ts
src/authorization/Authorizations.ts
@@ -602,7 +602,7 @@ export default class Authorizations {
}
public static canDownloadInvoiceBilling(loggedUser: UserToken): boolean {
- return Authorizations.canPerformAction(loggedUser, Entity.INVOICES, Action.DOWNLOAD);
+ return Authorizations.canPerformAction(loggedUser, Entity.INVOICE, Action.DOWNLOAD);
}
public static canCheckConnectionAsset(loggedUser: UserToken): boolean {
@@ -610,7 +610,7 @@ export default class Authorizations {
}
public static canRefreshAssetConnection(loggedUser: UserToken): boolean {
- return Authorizations.canPerformAction(loggedUser, Entity.ASSET, Action.REFRESH_CONNECTION);
+ return Authorizations.canPerformAction(loggedUser, Entity.ASSET, Action.RETRIEVE_CONSUMPTION);
}
public static isSuperAdmin(user: UserToken | User): boolean {

MODIFY
src/server/rest/service/AssetService.ts
src/server/rest/service/AssetService.ts
@@ -76,13 +76,13 @@ export default class AssetService {
public static async handleRetrieveConsumption(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Check if component is active
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ASSET,
- Action.REFRESH_CONNECTION, Entity.ASSET, MODULE_NAME, 'handleRetrieveConsumption');
+ Action.RETRIEVE_CONSUMPTION, Entity.ASSET, MODULE_NAME, 'handleRetrieveConsumption');
// Is authorized to check connection ?
if (!Authorizations.canRefreshAssetConnection(req.user)) {
throw new AppAuthError({
errorCode: HTTPAuthError.ERROR,
user: req.user,
- entity: Entity.ASSET, action: Action.REFRESH_CONNECTION,
+ entity: Entity.ASSET, action: Action.RETRIEVE_CONSUMPTION,
module: MODULE_NAME, method: 'handleRetrieveConsumption'
});
}

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -110,7 +110,7 @@ export enum Action {
SYNCHRONIZE_USER = 'SynchronizeUser',
SYNCHRONIZE_INVOICES = 'SynchronizeInvoices',
CHECK_CONNECTION = 'CheckConnection',
- REFRESH_CONNECTION = 'RefreshConnection',
+ RETRIEVE_CONSUMPTION = 'RefreshConnection',
PING = 'Ping',
GENERATE_LOCAL_TOKEN = 'GenerateLocalToken',
REGISTER = 'Register',

Updated Asset + Invoice auths