logger = $logger; $this->db = $db; } /** * Authenticate user. * * @param $username The username for authentication * @param $password The password for authentication * * @return true if valid false otherwise */ public function authenticate(string $username, string $password) : bool { $query = $this->db->prepare('SELECT id, password FROM users WHERE name=:name AND backend=\'native\''); $query->bindValue(':name', $username, \PDO::PARAM_STR); $query->execute(); $record = $query->fetch(); if ($record === false) { return false; } return password_verify($password, $record['password']); } }