chore (fetch datas) #39 : fermeture curseur sql après login$ #40

Merged
mlamalle merged 2 commits from issue-39 into develop 2024-09-24 10:37:17 +02:00
1 changed files with 8 additions and 1 deletions
Showing only changes of commit 085533b299 - Show all commits

View File

@ -26,6 +26,9 @@ 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) {
@ -44,11 +47,15 @@ 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 +82,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,