From 6a8c0b3f99710115cc4e1e413ad434be7a920c0b Mon Sep 17 00:00:00 2001 From: Mason James Date: Mon, 23 Mar 2015 12:06:27 +1300 Subject: [PATCH] Bug 13871 - OverDrive message when user authentication fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NOTE: apply this patch after the additional perltidy patch this patch is basically a small work-around to fix some confusing login text, when users enter incorrect auth details via Overdrive's website with this option disabled (default) there is no change to SIP's behaviour to test... 1/ configure your overdrive account to talk to your Koha's SIP service 2/ start Koha's SIP 3/ enter a correct username and correct password in overdrive see overdrive display '(1) Greetings from Koha…' (good) 4/ enter a correct username and *incorrect* password in overdrive see overdrive display '(1) Greetings from Koha…' (bad) 5/ enter an incorrect username in overdrive see overdrive display '(1)' (badder) 6/ apply patch, enable 'overdrive-mode' in Koha's SIPConfig.xml example... --------------------- --------------------- 7/ restart SIP 8/ enter a correct username and correct password see overdrive display '(1) Greetings from Koha…' 9/ enter a correct username and *incorrect* password see overdrive display '(1) Invalid patron or patron password' 10/ enter an incorrect username and incorrect password see overdrive display '(1) Invalid patron or patron password' http://bugs.koha-community.org/show_bug.cgi?id=1387 --- C4/SIP/Sip/MsgType.pm | 34 +++++++++++++++++++++++++++------- 1 files changed, 27 insertions(+), 7 deletions(-) diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 4739c2f..b3e23ee 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -429,14 +429,29 @@ sub handle { # ASSUMPTION: If the patron password field is present in the # message, then it must match, otherwise incomplete patron status # information will be returned to the terminal. -# +# sub build_patron_status { my ( $patron, $lang, $fields, $server ) = @_; - + my $overdrive_mode = $server->{account}->{'overdrive-mode'}; my $patron_pwd = $fields->{ (FID_PATRON_PWD) }; my $resp = (PATRON_STATUS_RESP); + my $password_ok = 1; + my $password_rc; if ($patron) { + if ($patron_pwd) { + $password_rc = $patron->check_password($patron_pwd); + $password_ok = 0 unless $password_rc; + } + elsif ( $overdrive_mode + and not exists $fields->{'AL'} # not block_request + and not $patron_pwd ) # no password supplied + { + $password_ok = 0; + } + } + + if ( $patron and $password_ok ) { $resp .= patron_status_string($patron); $resp .= $lang . Sip::timestamp(); $resp .= add_field( FID_PERSONAL_NAME, $patron->name ); @@ -444,13 +459,12 @@ sub build_patron_status { # while the patron ID we got from the SC is valid, let's # use the one returned from the ILS, just in case... $resp .= add_field( FID_PATRON_ID, $patron->id ); + if ( $protocol_version >= 2 ) { $resp .= add_field( FID_VALID_PATRON, 'Y' ); # Patron password is a required field. - $resp .= - add_field( FID_VALID_PATRON_PWD, - sipbool( $patron->check_password($patron_pwd) ) ); + $resp .= add_field( FID_VALID_PATRON_PWD, sipbool($password_rc) ); $resp .= maybe_add( FID_CURRENCY, $patron->currency ); $resp .= maybe_add( FID_FEE_AMT, $patron->fee_amount ); } @@ -458,11 +472,14 @@ sub build_patron_status { $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg ); $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode} ) if ( $server->{account}->{send_patron_home_library_in_af} ); - $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line ); + } else { - # Invalid patron id. Report that the user has no privs., + + # Invalid patron id (and/or passwd for overdrive_mode) + # Report that the user has no privs. + # no personal name, and is invalid (if we're using 2.00) $resp .= 'YYYY' . ( ' ' x 10 ) . $lang . Sip::timestamp(); $resp .= add_field( FID_PERSONAL_NAME, '' ); @@ -473,6 +490,9 @@ sub build_patron_status { ( $protocol_version >= 2 ) and $resp .= add_field( FID_VALID_PATRON, 'N' ); + + $resp .= + maybe_add( FID_SCREEN_MSG, 'Invalid patron or patron password' ); } $resp .= add_field( FID_INST_ID, $fields->{ (FID_INST_ID) } ); -- 1.7.2.5