Skip to content
Snippets Groups Projects
Commit 6386593e authored by Ere Maijala's avatar Ere Maijala Committed by Demian Katz
Browse files

Simplified patronLogin; eliminated SQL vulnerability.

parent f81d8f76
No related merge requests found
......@@ -440,39 +440,35 @@ class NewGenLib extends AbstractBase
*/
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
];
}
/**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment