I am trying to integrate phpass library with an existing authenticate method:
public static function authenticate($username, $password)
{
global $db;
$username = $db->prep_query($username);
$password = $db->prep_query($password); // Does not seems like it will be used
# First step: Retrieve the account based on the user input (email)
$query_string = "SELECT * FROM users WHERE email = '{$username}' LIMIT 1";
$query_result = static::find_by_query_string($query_string);
return !empty($query_result) ? array_shift($query_result) : false;
}
Now the record that comes back is ( according to print_r($query_result) )
Array ( [0] => User Object ( [id] => 7 [password] => $2a$08$qwSjSZ11TUYs5w1L89ppFer2n40HrnjlvaQ00DsUOOvjSYwoEmN4K [email] => test@user.com ) ) 1
What I’m trying to retrieve is: "$2a$08$qwSjSZ11TUYs5w1L89ppFer2n40HrnjlvaQ00DsUOOvjSYwoEmN4K"
But when I use $query_result[0][1] or $query_result[0]["password] I’m getting an error.
What am I missing here? How can I use the password value in $query_string array ?
You access the first array index, which happens to be an object. So you then need to access the property called password.