@@ -591,12 +591,14 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
591591
592592 MO_DBG_DEBUG (" Begin transaction process (%s), prepare" , idTag != nullptr ? idTag : " " );
593593
594- AuthorizationData *localAuth = nullptr ;
594+ bool localAuthFound = false ;
595+ const char *parentIdTag = nullptr ; // locally stored parentIdTag
595596 bool offlineBlockedAuth = false ; // if offline authorization will be blocked by local auth list entry
596597
597598 // check local OCPP whitelist
598- if (model.getAuthorizationService ()) {
599- localAuth = model.getAuthorizationService ()->getLocalAuthorization (idTag);
599+ #if MO_ENABLE_LOCAL_AUTH
600+ if (auto authService = model.getAuthorizationService ()) {
601+ auto localAuth = authService->getLocalAuthorization (idTag);
600602
601603 // check authorization status
602604 if (localAuth && localAuth->getAuthorizationStatus () != AuthorizationStatus::Accepted) {
@@ -611,21 +613,26 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
611613 offlineBlockedAuth = true ;
612614 localAuth = nullptr ;
613615 }
616+
617+ if (localAuth) {
618+ localAuthFound = true ;
619+ parentIdTag = localAuth->getParentIdTag ();
620+ }
614621 }
622+ #endif // MO_ENABLE_LOCAL_AUTH
615623
616624 int reservationId = -1 ;
617625 bool offlineBlockedResv = false ; // if offline authorization will be blocked by reservation
618626
619- #if MO_ENABLE_V16_RESERVATION
620627 // check if blocked by reservation
628+ #if MO_ENABLE_V16_RESERVATION
621629 if (model.getReservationService ()) {
622- const char *parentIdTag = localAuth ? localAuth->getParentIdTag () : nullptr ;
623630
624631 auto reservation = model.getReservationService ()->getReservation (
625632 connectorId,
626633 idTag,
627634 parentIdTag);
628-
635+
629636 if (reservation) {
630637 reservationId = reservation->getReservationId ();
631638 }
@@ -645,12 +652,14 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
645652 } else {
646653 // parentIdTag unkown but local authorization failed in any case
647654 MO_DBG_INFO (" connector %u reserved - no local auth" , connectorId);
648- localAuth = nullptr ;
655+ localAuthFound = false ;
649656 }
650657 }
651658 }
659+ #else
660+ (void )parentIdTag;
652661 #endif // MO_ENABLE_V16_RESERVATION
653-
662+
654663 transaction = allocateTransaction ();
655664
656665 if (!transaction) {
@@ -668,7 +677,7 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
668677 transaction->setBeginTimestamp (model.getClock ().now ());
669678
670679 // check for local preauthorization
671- if (localAuth && localPreAuthorizeBool && localPreAuthorizeBool->getBool ()) {
680+ if (localAuthFound && localPreAuthorizeBool && localPreAuthorizeBool->getBool ()) {
672681 MO_DBG_DEBUG (" Begin transaction process (%s), preauthorized locally" , idTag != nullptr ? idTag : " " );
673682
674683 if (reservationId >= 0 ) {
@@ -735,7 +744,6 @@ std::shared_ptr<Transaction> Connector::beginTransaction(const char *idTag) {
735744 });
736745
737746 // capture local auth and reservation check in for timeout handler
738- bool localAuthFound = localAuth;
739747 authorize->setOnTimeoutListener ([this , tx,
740748 offlineBlockedAuth,
741749 offlineBlockedResv,
0 commit comments