Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
campbell-m committed Apr 27, 2024
1 parent e2cf121 commit adaa571
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions web/lib/MRBS/Auth/AuthDbExt.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,29 @@ public function validateUser(
#[\SensitiveParameter]
?string $pass)
{
$retval = false;

// syntax_casesensitive_equals() modifies our SQL params array for us. We need an exact match -
// MySQL allows trailing spaces when using an '=' comparison, eg 'john' = 'john '

$sql_params = array();

$query = "SELECT " . $this->connection()->quote($this->column_name_password) .
"FROM " . $this->connection()->quote($this->db_table) .
"WHERE " . $this->connection()->syntax_casesensitive_equals($this->column_name_username,
$user,
$sql_params);
"FROM " . $this->connection()->quote($this->db_table) .
"WHERE " . $this->connection()->syntax_casesensitive_equals($this->column_name_username,
$user,
$sql_params);

$stmt = $this->connection()->query($query, $sql_params);

if ($stmt->count() == 1) // force a unique match
if ($stmt->count() === 1) // force a unique match
{
$row = $stmt->next_row();
$retval = ($this->password_check($pass, $row[0])) ? $user : false;
if ($this->password_check($pass, $row[0]))
{
return $user;
}
}

return $retval;
return false;
}


Expand Down

0 comments on commit adaa571

Please sign in to comment.