From 8637627dc9c99b2f1e47b4748c7e4360dbaac5f1 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 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 Signed-off-by: Kyle M Hall Signed-off-by: Marcel de Rooy Signed-off-by: Brendan A Gallagher --- C4/SIP/Sip/MsgType.pm | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index b0607df02f..451f22887a 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -406,11 +406,26 @@ sub handle { # 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 . timestamp(); $resp .= add_field( FID_PERSONAL_NAME, $patron->name ); @@ -418,11 +433,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 ); } @@ -430,11 +446,12 @@ sub build_patron_status { $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server ); $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server ) 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 . timestamp(); $resp .= add_field( FID_PERSONAL_NAME, '' ); @@ -445,6 +462,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) } ); -- 2.39.5