From 456e6759f65c79832bb2b119492d07e4a5ee6efd Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 20 Sep 2018 16:52:27 -0400 Subject: [PATCH] LP#1772680: add some guards Avoid crashes if the RBDigital API is not available or incorrect tokens are configured. Signed-off-by: Galen Charlton --- Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI.pm | 1 + Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI/RBDigital.pm | 6 +----- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader/RBDigitalSearch.pm | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI.pm index e80e07959a..061cc0aa04 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI.pm @@ -956,6 +956,7 @@ sub get_patron_id { $logger->error("EbookAPI: User Authenticated. Now, calling for patron authentication"); my $handler = new_handler($session_id); + return unless defined $handler; return $handler->do_patron_auth($editor->requestor->usrname, $editor->requestor->email); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI/RBDigital.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI/RBDigital.pm index e56a6739d6..50306529ce 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI/RBDigital.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/EbookAPI/RBDigital.pm @@ -204,17 +204,13 @@ sub _get_patron_id { }; my $res = $self->request($req, $session_id); - if ($res && defined($res->{content}->{patronId})) { - $self->{patron_id} = $res->{content}->{patronId}; - return $res->{content}->{patronId}; - } if (defined ($res)) { if ($res->{is_success} && defined($res->{content}->{patronId}) ) { $self->{patron_id} = $res->{content}->{patronId}; return $res->{content}->{patronId}; } else { - $logger->error("EbookAPI: Unable to get patron Id from RBDigital portal: ".$res->{content}->{message}); + $logger->error("EbookAPI: Unable to get patron Id from RBDigital portal: ".$res->{content}); return 0; } } else { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/RBDigitalSearch.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/RBDigitalSearch.pm index 9123fe22d5..b11dab6e9a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/RBDigitalSearch.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/RBDigitalSearch.pm @@ -403,8 +403,8 @@ sub _get_patron_id { my $ebook_api = OpenSRF::AppSession->create('open-ils.ebook_api'); my $api_request = $ebook_api->request('open-ils.ebook_api.get_patron_id', $authtoken, $session_id,0); - if ($api_request) { - return $api_request->recv->content; + if (my $resp = $api_request->recv) { + return $resp->content; } return 0; -- 2.11.0