From fd568e74beb69e28f3bd426c46ed1130aef183e3 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sun, 14 Sep 2014 13:45:35 -0400 Subject: [PATCH] Add AuthenticationInput checks for more messages in NCIP::ILS. We add the AUTHENTICATIONINPUT_MESSAGES constant to hold a list of messages that may have AuthenticationInput set, and then we check if our message is in the list when trying to find a user barcode and the UserId field was not present. Signed-off-by: Jason Stephenson --- lib/NCIP/Const.pm | 5 ++++- lib/NCIP/ILS.pm | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/NCIP/Const.pm b/lib/NCIP/Const.pm index 05c9cea..661c1b2 100644 --- a/lib/NCIP/Const.pm +++ b/lib/NCIP/Const.pm @@ -24,5 +24,8 @@ use constant SUPPORTED_VERSIONS => ( 'http://www.niso.org/schemas/ncip/v2_02/ncip_v2_02.xsd', ); - +# Messages for which AuthenticationInput are valid. +use constant AUTHENTICATIONINPUT_MESSAGES => ( + 'LookUpUser', 'RenewItem', 'CheckOutItem', 'RequestItem', +); 1; diff --git a/lib/NCIP/ILS.pm b/lib/NCIP/ILS.pm index 3173ed0..941f201 100644 --- a/lib/NCIP/ILS.pm +++ b/lib/NCIP/ILS.pm @@ -324,13 +324,12 @@ sub find_user_barcode { my $field; my $message = $self->parse_request_type($request); - # Check for UserId first because it is more common and valid - # in most messages. + # Check for UserId first because it is valid in all messages. my $authinput = $request->{$message}->{UserId}; if ($authinput) { $field = 'UserIdentifierValue'; $barcode = $authinput->{$field}; - } elsif ($message eq 'LookupUser') { + } elsif (grep {$_ eq $message} NCIP::Const::AUTHENTICATIONINPUT_MESSAGES) { $field = 'AuthenticationInputData'; $authinput = $request->{$message}->{AuthenticationInput}; # Convert to array ref if it isn't already. -- 2.11.0