From dc957af3ea95ffa4b16fe21c87ae0b12bc2ae67f Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Mon, 29 Sep 2014 07:51:42 +0000
Subject: [PATCH] BUG8446, QA Followup: Use DBIx::Class
- Convert Auth_with_shibboleth to use dbic stanzas.
---
C4/Auth_with_shibboleth.pm | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/C4/Auth_with_shibboleth.pm b/C4/Auth_with_shibboleth.pm
index d2a4cdf..6d2c08d 100644
--- a/C4/Auth_with_shibboleth.pm
+++ b/C4/Auth_with_shibboleth.pm
@@ -21,6 +21,7 @@ use Modern::Perl;
use C4::Debug;
use C4::Context;
+use Koha::Database;
use Carp;
use CGI;
@@ -94,16 +95,12 @@ sub checkpw_shib {
my $config = _get_shib_config();
$debug and warn "User Shibboleth-authenticated as: $match";
- # Does the given shibboleth attribute value ($match) match a valid koha user ?
- my $sth = $dbh->prepare(
- "select cardnumber, userid from borrowers where $config->{matchpoint}=?"
- );
- $sth->execute($match);
- if ( $sth->rows ) {
- my @retvals = $sth->fetchrow;
- $retnumber = $retvals[0];
- $userid = $retvals[1];
- return ( 1, $retnumber, $userid );
+ # Does the given shibboleth attribute value ($match) match a valid koha user ?
+ my $borrower =
+ Koha::Database->new()->schema()->resultset('Borrower')
+ ->find( { $config->{matchpoint} => $match } );
+ if ( defined($borrower) ) {
+ return ( 1, $borrower->get_column('cardnumber'), $borrower->get_column('userid') );
}
# If we reach this point, the user is not a valid koha user
--
1.7.10.4