feat (gestion exception) #19: modification fetchPassword
Some checks reported warnings
Cadoles/hydra-sql/pipeline/pr-develop This commit is unstable

This commit is contained in:
2024-04-29 11:09:58 +02:00
parent 0791727694
commit 51c92a0dba
3 changed files with 43 additions and 44 deletions

View File

@ -8,6 +8,7 @@ use App\SQLLogin\Exception\LoginElementsConfigurationException;
use App\SQLLogin\Exception\NullDataToFetchException;
use App\SQLLogin\SQLLoginConnect;
use App\SQLLogin\SQLLoginRequest;
use Exception;
use PDO;
use PDOException;
use Psr\Log\LoggerInterface;
@ -51,7 +52,7 @@ class SQLLoginService extends AbstractController
return $datas;
}
public function fetchPassword($login): array|bool
public function fetchPassword(string $login): array
{
try {
$dbh = $this->getConnection();
@ -71,14 +72,14 @@ class SQLLoginService extends AbstractController
$this->loggerInterface->critical($e->getMessage());
throw new LoginElementsConfigurationException($e->getMessage());
}
if ($password) {
return [
$password[$this->sqlLoginRequest->getPasswordColumnName()],
isset($password[$this->sqlLoginRequest->getSaltColumnName()]) ? $password[$this->sqlLoginRequest->getSaltColumnName()] : null,
];
if (!$password) {
throw new Exception('Une erreur est survenue lors de la récupération des données');
}
return false;
return [
$password[$this->sqlLoginRequest->getPasswordColumnName()],
isset($password[$this->sqlLoginRequest->getSaltColumnName()]) ? $password[$this->sqlLoginRequest->getSaltColumnName()] : null,
];
}
public function getConnection(): PDO