params = $params; $this->pdoRequest = $pdoRequest; } public function fetchDatas($login) { try { $dbh = $this->getConnection(); // forge de la requête $request = $this->pdoRequest->getRequestScope(); // Préparation de la requête $query = $dbh->prepare($request); $query->execute([$this->pdoRequest->getNameLogin() => $login]); $datas = $query->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { \Sentry\captureException($e); throw new PDOException(); } return $datas; } /** * @param mixed $login * * @return bool */ public function fetchPassword($login) { try { $dbh = $this->getConnection(); $request = $this->pdoRequest->getRequestLogin(); $query = $dbh->prepare($request); $query->execute([$this->pdoRequest->getNameLogin() => $login]); $password = $query->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { \Sentry\captureException($e); dd($e); throw new PDOException(); } if ($password) { return $password[$this->pdoRequest->getNamePassword()]; } return false; } public function getConnection() { // Appel du singleton $pdo = PdoConnect::getInstance(); // Connection bdd return $pdo->connect($this->pdoRequest->getDatabaseDsn(), $this->pdoRequest->getDbUser(), $this->pdoRequest->getDbPassword()); } public function verifyPassword($password, $hashedPassword) { $hashAlgo = $this->params->get('hashAlgo') ?? 'sha256'; if ($hashedPassword === hash($hashAlgo, $password)) { return true; } else { throw new InvalidPasswordException(); } } }