Compare commits
No commits in common. "27f957124b8c64ddf21153c2a00b4c19478932a2" and "5bfd8991ee66db8441388aa7b18559c7049e9929" have entirely different histories.
27f957124b
...
5bfd8991ee
@ -13,8 +13,9 @@ class SQLLoginConnect extends AbstractController
|
||||
* Méthode qui crée l'unique instance de la classe
|
||||
* si elle n'existe pas encore puis la retourne.
|
||||
*
|
||||
* @return SQLLoginConnect
|
||||
*/
|
||||
public static function getInstance(): SQLLoginConnect
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(self::$_instance)) {
|
||||
self::$_instance = new SQLLoginConnect();
|
||||
@ -23,7 +24,7 @@ class SQLLoginConnect extends AbstractController
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
public function connect($urlDatabase, $dbUser, $dbPassword): PDO
|
||||
public function connect($urlDatabase, $dbUser, $dbPassword)
|
||||
{
|
||||
return new PDO($urlDatabase, $dbUser, $dbPassword);
|
||||
}
|
||||
|
@ -26,9 +26,6 @@ class SQLLoginService extends AbstractController
|
||||
|
||||
public function fetchDatas(string $login): array
|
||||
{
|
||||
if (empty($login)) {
|
||||
throw new Exception('Connexion échouée, le login ne peut pas être vide');
|
||||
}
|
||||
try {
|
||||
$dbh = $this->getConnection();
|
||||
} catch (PDOException $e) {
|
||||
@ -47,15 +44,11 @@ class SQLLoginService extends AbstractController
|
||||
$query = $dbh->prepare($request);
|
||||
$query->execute([$this->sqlLoginRequest->getLoginColumnName() => $login]);
|
||||
$datas = $query->fetch(PDO::FETCH_ASSOC);
|
||||
$query->closeCursor();
|
||||
} catch (PDOException $e) {
|
||||
$this->loggerInterface->critical($e->getMessage());
|
||||
throw new DataToFetchConfigurationException($e->getMessage());
|
||||
}
|
||||
|
||||
if (false === $datas) {
|
||||
throw new Exception(sprintf('La requête sql "%s" a renvoyé un résultat incorrect.', $request));
|
||||
}
|
||||
return $datas;
|
||||
}
|
||||
|
||||
@ -75,7 +68,6 @@ class SQLLoginService extends AbstractController
|
||||
$query = $dbh->prepare($request);
|
||||
$query->execute([$this->sqlLoginRequest->getLoginColumnName() => $login]);
|
||||
$password = $query->fetch(PDO::FETCH_ASSOC);
|
||||
$query->closeCursor();
|
||||
} catch (PDOException $e) {
|
||||
$this->loggerInterface->critical($e->getMessage());
|
||||
throw new LoginElementsConfigurationException($e->getMessage());
|
||||
@ -83,6 +75,7 @@ class SQLLoginService extends AbstractController
|
||||
if (!$password) {
|
||||
throw new Exception('Une erreur est survenue lors de la récupération des données');
|
||||
}
|
||||
|
||||
return [
|
||||
$password[$this->sqlLoginRequest->getPasswordColumnName()],
|
||||
isset($password[$this->sqlLoginRequest->getSaltColumnName()]) ? $password[$this->sqlLoginRequest->getSaltColumnName()] : null,
|
||||
|
Loading…
Reference in New Issue
Block a user