@@ -2246,34 +2246,32 @@ void ChargePointImpl::handleRemoteStartTransactionRequest(ocpp::Call<RemoteStart
22462246bool ChargePointImpl::validate_against_cache_entries (CiString<20 > id_tag) {
22472247 try {
22482248 const auto cache_entry_opt = this ->database_handler ->get_authorization_cache_entry (id_tag);
2249- if (cache_entry_opt.has_value ()) {
2250- auto cache_entry = cache_entry_opt.value ();
2251- const auto expiry_date_opt = cache_entry.expiryDate ;
2252-
2253- if (cache_entry.status == AuthorizationStatus::Accepted) {
2254- if (expiry_date_opt.has_value ()) {
2255- const auto expiry_date = expiry_date_opt.value ();
2256- if (expiry_date < ocpp::DateTime ()) {
2257- cache_entry.status = AuthorizationStatus::Expired;
2258- try {
2259- this ->database_handler ->insert_or_update_authorization_cache_entry (id_tag, cache_entry);
2260- } catch (const QueryExecutionException& e) {
2261- EVLOG_warning << " Could not insert or update authorization cache entry: " << e.what ();
2262- }
2263- return false ;
2264- } else {
2265- return true ;
2266- }
2267- return false ;
2268- }
2269- return true ;
2270- }
2249+ if (!cache_entry_opt.has_value ()) {
2250+ return false ;
2251+ }
2252+ auto cache_entry = cache_entry_opt.value ();
2253+ const auto expiry_date_opt = cache_entry.expiryDate ;
2254+
2255+ if (cache_entry.status != AuthorizationStatus::Accepted) {
2256+ return false ;
2257+ }
2258+ if (!expiry_date_opt.has_value ()) {
22712259 return true ;
22722260 }
2261+ const auto expiry_date = expiry_date_opt.value ();
2262+ if (expiry_date < ocpp::DateTime ()) {
2263+ cache_entry.status = AuthorizationStatus::Expired;
2264+ try {
2265+ this ->database_handler ->insert_or_update_authorization_cache_entry (id_tag, cache_entry);
2266+ } catch (const QueryExecutionException& e) {
2267+ EVLOG_warning << " Could not insert or update authorization cache entry: " << e.what ();
2268+ }
2269+ return false ;
2270+ }
2271+ return true ;
22732272 } catch (const QueryExecutionException& e) {
22742273 EVLOG_warning << " Could not fetch authorization cache entry: " << e.what ();
22752274 }
2276- return false ;
22772275}
22782276
22792277void ChargePointImpl::handleRemoteStopTransactionRequest (ocpp::Call<RemoteStopTransactionRequest> call) {
0 commit comments