From 274271b59d5491dc44ebe7bbfb12da13e96d2ceb Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 19 Dec 2018 17:53:08 +0000 Subject: [PATCH] Bug 22030: Use preference to determine username sent to overdrive Overdrive configuration generally defaults to cardnumber, however, they have confirmed that some libraries use usernames. We need to allow for both scenarios. To test: 1 - Have an OverDrive account setup with SIP authentication Note: You can apply for a testing account at developer.overdrive.com and setup an environment 2 - Fill in all your OverDrive system preferences 3 - Test with a patron whose username is their cardnumber 4 - Confirm their overdrive account tab on opac loads 5 - Change the username to be another value like "borked_wont_work" 6 - Note the overdrive account tab won't load 7 - Apply patch, update database, not new system preference OverDriveUsername (default to 'cardnumber) 8 - Note the OD account loads successfully 9 - Change the system preference to 'user name' - the account load fails Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens (cherry picked from commit 96adab7af8999da7f351169e1265d4be5e59742f) Signed-off-by: Martin Renvoize --- ...ug_22030_add_OverDriveUsername_system_preference.perl | 9 +++++++++ installer/data/mysql/sysprefs.sql | 1 + .../en/modules/admin/preferences/enhanced_content.pref | 6 ++++++ opac/svc/overdrive | 8 +++++++- 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_22030_add_OverDriveUsername_system_preference.perl diff --git a/installer/data/mysql/atomicupdate/bug_22030_add_OverDriveUsername_system_preference.perl b/installer/data/mysql/atomicupdate/bug_22030_add_OverDriveUsername_system_preference.perl new file mode 100644 index 0000000000..73047781ac --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_22030_add_OverDriveUsername_system_preference.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('OverDriveUsername','cardnumber','cardnumber|userid','Which patron information should be passed as OverDrive username','Choice') + }); + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug XXXXX - description)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 1e36c306c6..072ca5bb6a 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -431,6 +431,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OverDriveClientSecret','','Client key for OverDrive integration','30','YesNo'), ('OverDriveLibraryID','','Library ID for OverDrive integration','','Integer'), ('OverDrivePasswordRequired','',NULL,'Does the library require passwords for OverDrive SIP authentication','YesNo'), +('OverDriveUsername','cardnumber','cardnumber|userid','Which patron information should be passed as OverDrive username','Choice'), ('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'), ('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'), ('OverduesBlockRenewing','allow','allow|blockitem|block','If any of patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','Choice'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref index 67db1fbb01..f6e01e2ea2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref @@ -384,6 +384,12 @@ Enhanced Content: yes: Enable no: "Don't enable" - users to access their OverDrive circulation history, and circulate items.
+ - Overdrive uses the patron's + - pref: OverDriveUsername + choices: + cardnumber: cardnumber + userid: user name + - for user access to OverDrive.
- A password is - pref: OverDrivePasswordRequired choices: diff --git a/opac/svc/overdrive b/opac/svc/overdrive index 3ede3f4fdb..57333f0066 100755 --- a/opac/svc/overdrive +++ b/opac/svc/overdrive @@ -48,9 +48,15 @@ eval { my $password = $cgi->param("password") // q{} ; my $patron = Koha::Patrons->find({ userid => $user }); my $branch_info = $patron ? Koha::Library::OverDriveInfos->find( $patron->branchcode ) : undef; + my $od_username; + if ( C4::Context->preference('OverDriveUsername') eq 'cardnumber' ){ + $od_username = $patron ? $patron->cardnumber : undef; + } else { + $od_username = $user; + } my $branch_authname = $branch_info ? $branch_info->authname : undef; my $authname = $branch_authname || C4::Context->preference('OverDriveAuthname'); - $od->auth_by_userid($user, $password,C4::Context->preference('OverDriveWebsiteID'),$authname); + $od->auth_by_userid($od_username, $password,C4::Context->preference('OverDriveWebsiteID'),$authname); $data{login_success} = 1; last; }; -- 2.39.5