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 <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2018-12-19 17:53:08 +00:00
parent 482b323da1
commit 96adab7af8
4 changed files with 23 additions and 1 deletions

View file

@ -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";
}

View file

@ -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'),

View file

@ -384,6 +384,12 @@ Enhanced Content:
yes: Enable
no: "Don't enable"
- users to access their OverDrive circulation history, and circulate items.<br />
- Overdrive uses the patron's
- pref: OverDriveUsername
choices:
cardnumber: cardnumber
userid: user name
- for user access to OverDrive. <br />
- A password is
- pref: OverDrivePasswordRequired
choices:

View file

@ -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;
};