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 <jason@sigio.com>
'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;
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.