Add debug in OCPP authorize
MODIFY
src/authorization/Authorizations.ts
src/authorization/Authorizations.ts
@@ -761,9 +761,8 @@ export default class Authorizations {
transaction: Transaction, tagID: string, action: ServerAction, authAction: Action): Promise<User> {
// Get the Organization component
const tenant: Tenant = await TenantStorage.getTenant(tenantID);
- const isOrgCompActive = Utils.isTenantComponentActive(tenant, TenantComponents.ORGANIZATION);
// Org component enabled?
- if (isOrgCompActive) {
+ if (Utils.isTenantComponentActive(tenant, TenantComponents.ORGANIZATION)) {
let foundSiteArea = true;
// Site Area -----------------------------------------------
if (!chargingStation.siteAreaID) {
@@ -783,6 +782,7 @@ export default class Authorizations {
action: action,
module: MODULE_NAME, method: 'isTagIDAuthorizedOnChargingStation',
message: `Charging Station '${chargingStation.id}' is not assigned to a Site Area!`,
+ detailedMessages: { chargingStation }
});
}
// Access Control is disabled?
@@ -791,9 +791,8 @@ export default class Authorizations {
return UserStorage.getUserByTagId(tenantID, tagID);
}
// Site -----------------------------------------------------
- chargingStation.siteArea.site = chargingStation.siteArea.site ?
- chargingStation.siteArea.site : (chargingStation.siteArea.siteID ?
- await SiteStorage.getSite(tenantID, chargingStation.siteArea.siteID) : null);
+ chargingStation.siteArea.site = chargingStation.siteArea.site ??
+ (chargingStation.siteArea.siteID ? await SiteStorage.getSite(tenantID, chargingStation.siteArea.siteID) : null);
if (!chargingStation.siteArea.site) {
// Reject Site Not Found
throw new BackendError({
@@ -801,6 +800,7 @@ export default class Authorizations {
action: action,
module: MODULE_NAME, method: 'isTagIDAuthorizedOnChargingStation',
message: `Site Area '${chargingStation.siteArea.name}' is not assigned to a Site!`,
+ detailedMessages: { chargingStation }
});
}
}
@@ -862,7 +862,8 @@ export default class Authorizations {
source: chargingStation.id,
action: action,
module: MODULE_NAME, method: 'isTagIDAuthorizedOnChargingStation',
- message: `Tag ID '${tagID}' is unknown and has been created successfully as an inactive Tag`
+ message: `Tag ID '${tagID}' is unknown and has been created successfully as an inactive Tag`,
+ detailedMessages: { tag }
});
}
// Inactive Tag
@@ -871,9 +872,9 @@ export default class Authorizations {
source: chargingStation.id,
action: action,
message: `Tag ID '${tagID}' is not active`,
- module: MODULE_NAME,
- method: 'isTagIDAuthorizedOnChargingStation',
- user: tag.user
+ module: MODULE_NAME, method: 'isTagIDAuthorizedOnChargingStation',
+ user: tag.user,
+ detailedMessages: { tag }
});
}
// No User
@@ -882,9 +883,9 @@ export default class Authorizations {
source: chargingStation.id,
action: action,
message: `Tag ID '${tagID}' is not assigned to a User`,
- module: MODULE_NAME,
- method: 'isTagIDAuthorizedOnChargingStation',
- user: tag.user
+ module: MODULE_NAME, method: 'isTagIDAuthorizedOnChargingStation',
+ user: tag.user,
+ detailedMessages: { tag }
});
}
// Check User
@@ -911,7 +912,7 @@ export default class Authorizations {
tagIDs: userToken.tagIDs,
tagID: transaction ? transaction.tagID : null,
owner: userToken.id,
- site: isOrgCompActive && chargingStation.siteArea ? chargingStation.siteArea.site.id : null,
+ site: chargingStation.siteID,
sites: userToken.sites,
sitesAdmin: userToken.sitesAdmin
};
@@ -922,7 +923,8 @@ export default class Authorizations {
message: `User with Tag ID '${tagID}' is not authorized to perform the action '${authAction}'`,
module: MODULE_NAME,
method: 'isTagIDAuthorizedOnChargingStation',
- user: tag.user
+ user: tag.user,
+ detailedMessages: { userToken, tag }
});
}
}
@@ -934,7 +936,8 @@ export default class Authorizations {
user: user,
action: ServerAction.AUTHORIZE,
module: MODULE_NAME, method: 'isTagIDAuthorizedOnChargingStation',
- message: `Unable to authorize User with Tag ID '${tag.id}' not issued locally`
+ message: `Unable to authorize User with Tag ID '${tag.id}' not issued locally`,
+ detailedMessages: { tag }
});
}
// Got Token from OCPI
@@ -943,7 +946,8 @@ export default class Authorizations {
user: user,
action: ServerAction.AUTHORIZE,
module: MODULE_NAME, method: 'isTagIDAuthorizedOnChargingStation',
- message: `Tag ID '${tag.id}' cannot be authorized through OCPI protocol due to missing OCPI Token`
+ message: `Tag ID '${tag.id}' cannot be authorized through OCPI protocol due to missing OCPI Token`,
+ detailedMessages: { tag }
});
}
// Check Charging Station
@@ -952,7 +956,8 @@ export default class Authorizations {
user: user,
action: ServerAction.AUTHORIZE,
module: MODULE_NAME, method: 'isTagIDAuthorizedOnChargingStation',
- message: `Tag ID '${tag.id}' cannot be authorized on a private charging station`
+ message: `Tag ID '${tag.id}' cannot be authorized on a private charging station`,
+ detailedMessages: { tag, chargingStation }
});
}
// Request Authorization

Add debug in OCPP authorize