Final fix for canPerformAction. Also correct typo.
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -32,8 +32,7 @@ import _ from 'lodash';
const MODULE_NAME = 'AuthorizationService';
export default class AuthorizationService {
- public static canPerfomAction(authActions: AuthorizationActions, action: Action): boolean {
- const siteAreaAuthActions = <SiteAreaAuthorizationActions> authActions;
+ public static canPerformAction(authActions: AuthorizationActions | SiteAreaAuthorizationActions, action: Action): boolean {
switch (action) {
case Action.READ:
return authActions.canRead;
@@ -44,13 +43,13 @@ export default class AuthorizationService {
case Action.DELETE:
return authActions.canDelete;
case Action.ASSIGN_CHARGING_STATIONS:
- return siteAreaAuthActions.canAssignChargingStations;
+ return (authActions as SiteAreaAuthorizationActions).canAssignChargingStations;
case Action.UNASSIGN_CHARGING_STATIONS:
- return siteAreaAuthActions.canUnassignChargingStations;
+ return (authActions as SiteAreaAuthorizationActions).canUnassignChargingStations;
case Action.ASSIGN_ASSETS:
- return siteAreaAuthActions.canAssignAssets;
+ return (authActions as SiteAreaAuthorizationActions).canAssignAssets;
case Action.UNASSIGN_ASSETS:
- return siteAreaAuthActions.canUnassignAssets;
+ return (authActions as SiteAreaAuthorizationActions).canUnassignAssets;
default:
return false;
}

MODIFY
src/server/rest/v1/service/UtilsService.ts
src/server/rest/v1/service/UtilsService.ts
@@ -190,7 +190,7 @@ export default class UtilsService {
// Add actions
await AuthorizationService.addCompanyAuthorizations(tenant, userToken, company, authorizationFilter);
// Check
- const authorized = AuthorizationService.canPerfomAction(company, authAction);
+ const authorized = AuthorizationService.canPerformAction(company, authAction);
if (!authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
@@ -243,7 +243,7 @@ export default class UtilsService {
// Add actions
await AuthorizationService.addUserAuthorizations(tenant, userToken, user, authorizationFilter);
// Check
- const authorized = AuthorizationService.canPerfomAction(user, authAction);
+ const authorized = AuthorizationService.canPerformAction(user, authAction);
if (!authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
@@ -296,7 +296,7 @@ export default class UtilsService {
// Add actions
await AuthorizationService.addSiteAuthorizations(tenant, userToken, site, authorizationFilter, { SiteID: siteID });
// Check
- const authorized = AuthorizationService.canPerfomAction(site, authAction);
+ const authorized = AuthorizationService.canPerformAction(site, authAction);
if (!authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
@@ -499,7 +499,7 @@ export default class UtilsService {
// Add actions
await AuthorizationService.addSiteAreaAuthorizations(tenant, userToken, siteArea, authorizationFilter, { ID: siteAreaID });
// Check
- const authorized = AuthorizationService.canPerfomAction(siteArea, authAction);
+ const authorized = AuthorizationService.canPerformAction(siteArea, authAction);
if (!authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,

Final fix for canPerformAction. Also correct typo.