No BackendError for OICP user check in case that user is no roaming user
MODIFY
src/authorization/Authorizations.ts
src/authorization/Authorizations.ts
@@ -13,6 +13,7 @@ import Logging from '../utils/Logging';
import NotificationHandler from '../notification/NotificationHandler';
import OCPIClientFactory from '../client/ocpi/OCPIClientFactory';
import { OCPIRole } from '../types/ocpi/OCPIRole';
+import { OICPAuthorizationStatus } from '../types/oicp/OICPAuthentication';
import OICPClientFactory from '../client/oicp/OICPClientFactory';
import { OICPDefaultTagId } from '../types/oicp/OICPIdentification';
import { OICPRole } from '../types/oicp/OICPRole';
@@ -776,11 +777,10 @@ export default class Authorizations {
// Check OICP User
// OICP Active?
if (Utils.isTenantComponentActive(tenant, TenantComponents.OICP)) {
- // OICP user
- const virtualOICPUser = await UserStorage.getUserByEmail(tenantID, Constants.OICP_VIRTUAL_USER_EMAIL);
-
+ // OICP user?
+ // Check if user has remote authorization
if (tagID === OICPDefaultTagId.RemoteIdentification) {
- return virtualOICPUser;
+ return await UserStorage.getUserByEmail(tenantID, Constants.OICP_VIRTUAL_USER_EMAIL);
}
const oicpClient = await OICPClientFactory.getAvailableOicpClient(tenant, OICPRole.CPO) as CpoOICPClient;
if (!oicpClient) {
@@ -791,9 +791,11 @@ export default class Authorizations {
message: 'OICP component requires at least one CPO endpoint to start a Session'
});
}
+ // Check if user is OICP roaming user and authorized
// Call Hubject
const response = await oicpClient.authorizeStart(tagID);
- if (response.SessionID) {
+ if (response.AuthorizationStatus === OICPAuthorizationStatus.Authorized) {
+ const virtualOICPUser = await UserStorage.getUserByEmail(tenantID, Constants.OICP_VIRTUAL_USER_EMAIL);
virtualOICPUser.authorizationID = response.SessionID;
return virtualOICPUser;
}

MODIFY
src/client/oicp/CpoOICPClient.ts
src/client/oicp/CpoOICPClient.ts
@@ -635,7 +635,8 @@ export default class CpoOICPClient extends OICPClient {
requestError = error;
}
if (requestError) {
- throw new BackendError({
+ Logging.logError({
+ tenantID: this.tenant.id,
action: ServerAction.OICP_AUTHORIZE_START,
message: `'authorizeStart' Error: '${authorizeResponse?.StatusCode?.AdditionalInfo ? authorizeResponse?.StatusCode?.AdditionalInfo : authorizeResponse?.StatusCode?.Description}' '${String(requestError?.message)}`,
module: MODULE_NAME, method: 'authorizeStart',
@@ -648,7 +649,8 @@ export default class CpoOICPClient extends OICPClient {
});
}
if (authorizeResponse?.AuthorizationStatus !== OICPAuthorizationStatus.Authorized) {
- throw new BackendError({
+ Logging.logError({
+ tenantID: this.tenant.id,
action: ServerAction.OICP_AUTHORIZE_START,
module: MODULE_NAME, method: 'authorizeStart',
message: `User with Authorization '${tagID}' cannot ${TransactionAction.START} Transaction thought OICP protocol due to missing Authorization`,

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -480,6 +480,15 @@ export default class OCPPService {
// Check
const user = await Authorizations.isAuthorizedOnChargingStation(headers.tenantID, chargingStation,
authorize.idTag, ServerAction.AUTHORIZE, Action.AUTHORIZE);
+ if (!user) {
+ throw new BackendError({
+ user: user,
+ action: ServerAction.AUTHORIZE,
+ module: MODULE_NAME,
+ method: 'handleAuthorize',
+ message: 'Missing Authorization'
+ });
+ }
// Roaming User
if (user && !user.issuer && user.authorizationID) {
if (chargingStation.public) {

No BackendError for OICP user check in case that user is no roaming user