refactor: cleanup RFID authorization code
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 1 Aug 2023 23:47:42 +0000 (01:47 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 1 Aug 2023 23:47:42 +0000 (01:47 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/OCPPServiceUtils.ts

index b74740875b2753642eb673ae3dcd9a8cb5a3c89a..f5bbe1602290dbba4699600570c46a76a10c44f4 100644 (file)
@@ -232,7 +232,6 @@ export class OCPPServiceUtils {
         `${chargingStation.logPrefix()} The charging station expects to authorize RFID tags but nor local authorization nor remote authorization are enabled. Misbehavior may occur`,
       );
     }
-    let authorized = false;
     if (
       chargingStation.getLocalAuthListEnabled() === true &&
       OCPPServiceUtils.isIdTagLocalAuthorized(chargingStation, idTag)
@@ -240,15 +239,11 @@ export class OCPPServiceUtils {
       const connectorStatus: ConnectorStatus = chargingStation.getConnectorStatus(connectorId)!;
       connectorStatus.localAuthorizeIdTag = idTag;
       connectorStatus.idTagLocalAuthorized = true;
-      authorized = true;
+      return true;
     } else if (chargingStation.getRemoteAuthorization()) {
-      authorized = await OCPPServiceUtils.isIdTagRemoteAuthorized(
-        chargingStation,
-        connectorId,
-        idTag,
-      );
+      return await OCPPServiceUtils.isIdTagRemoteAuthorized(chargingStation, connectorId, idTag);
     }
-    return authorized;
+    return false;
   }
 
   protected static checkConnectorStatusTransition(