Skip to content

Commit

Permalink
Simplified patronLogin; eliminated SQL vulnerability.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala authored and demiankatz committed Apr 5, 2016
1 parent ba29923 commit c696cea
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions module/VuFind/src/VuFind/ILS/Driver/NewGenLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,39 +440,35 @@ public function getStatuses($StatusResult)
*/
public function patronLogin($username, $password)
{
$patron = [];
$PatId = $username;
$psswrd = $password;
//SQL Statement
$sql = "select p.patron_id as patron_id, p.library_id as library_id, " .
"p.fname as fname, p.lname as lname, p.user_password as " .
"user_password, p.membership_start_date as membership_start_date, " .
"p.membership_expiry_date as membership_expiry_date, p.email as " .
"email from patron p where p.patron_id='" . $PatId .
"' and p.user_password='" . $psswrd . "' and p.membership_start_date " .
"email from patron p where p.patron_id=:patronId" .
"' and p.user_password=:password and p.membership_start_date " .
"<= current_date and p.membership_expiry_date > current_date";

try {
$sqlStmt = $this->db->prepare($sql);
$sqlStmt->execute();
$sqlStmt->execute([':patronId' => $username, ':password' => $password]);
} catch (PDOException $e) {
throw new ILSException($e->getMessage());
}
while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) {
if ($PatId != $row['patron_id'] || $psswrd != $row['user_password']) {
return null;
} else {
$patron = ["id" => $PatId,
"firstname" => $row['fname'],
'lastname' => $row['lname'],
'cat_username' => $PatId,
'cat_password' => $psswrd,
'email' => $row['email'],
'major' => null,
'college' => null];
}
$row = $sqlStmt->fetch(PDO::FETCH_ASSOC);
if (!$row) {
return null;
}
return $patron;
return [
"id" => $row['patron_id'],
"firstname" => $row['fname'],
'lastname' => $row['lname'],
'cat_username' => $username,
'cat_password' => $password,
'email' => $row['email'],
'major' => null,
'college' => null
];
}

/**
Expand Down

0 comments on commit c696cea

Please sign in to comment.