You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
46 lines
1.2 KiB
<?php
|
|
|
|
namespace Gateway;
|
|
|
|
use Config\Connection;
|
|
use Config\ConnectClass;
|
|
use PDO;
|
|
use PDOException;
|
|
|
|
/**
|
|
* Permet d'accéder, d'écrire ou de modifier les données contenues dans la table Admin afin de gérer l'espace administrateur.
|
|
*/
|
|
class GatewayAdmin
|
|
{
|
|
/**
|
|
* @var Connection
|
|
*/
|
|
private Connection $connection;
|
|
|
|
public function __construct()
|
|
{
|
|
try{
|
|
$this->connection = (new ConnectClass)->connect();
|
|
}catch(PDOException $e){
|
|
throw new PDOException($e->getMessage(), $e->getCode(), $e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Permet de récupérer le mot de passe de l'administrateur en fonction de son login.
|
|
* @param String $login Le login de l'administrateur.
|
|
* @return String|null Le mot de passe de l'administrateur ou null si l'administrateur n'existe pas.
|
|
*/
|
|
|
|
public function getPasswordWithLogin(String $login): ?string
|
|
{
|
|
$query = "SELECT password FROM `admin` WHERE username = :username";
|
|
$this->connection->executeQuery($query, array(
|
|
':username' => array($login, PDO::PARAM_STR)
|
|
));
|
|
$result = $this->connection->getResults();
|
|
if(empty($result))
|
|
return null;
|
|
return $result[0]['password'];
|
|
}
|
|
} |