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.
49 lines
1.3 KiB
49 lines
1.3 KiB
<?php
|
|
|
|
class ControllerLoginAdmin
|
|
{
|
|
private $gatewayAdministrator;
|
|
|
|
function __construct()
|
|
{
|
|
global $dns, $user, $pass, $vues, $twig;
|
|
session_start();
|
|
try {
|
|
|
|
$con = new Connection($dns, $user, $pass);
|
|
|
|
$this->gatewayAdministrator = new GatewayAdministrator($con);
|
|
|
|
echo $twig->render($vues["loginAdmin"], [
|
|
'error' => $_SESSION["error"],
|
|
]);
|
|
|
|
$_SESSION["error"]="";
|
|
|
|
} catch (PDOException $e) {
|
|
// $dataVueEreur[] = "Erreur inattendue!!! ";
|
|
// require(__DIR__.'/../vues/erreur.php');
|
|
} catch (Exception $e2) {
|
|
// $dataVueEreur[] = "Erreur inattendue!!! ";
|
|
// require ($rep.$vues['erreur']);
|
|
}
|
|
}
|
|
|
|
function verify(){
|
|
$username = $_POST['username'];
|
|
$password = $_POST['password'];
|
|
|
|
$Administrator = new Administrator($username, $password);
|
|
|
|
$AdministratorIsOk = $this->gatewayAdministrator->verifyAdministrator($Administrator);
|
|
if($AdministratorIsOk != null) {
|
|
$_SESSION["idAdminConnected"]=$AdministratorIsOk;
|
|
header("Location:/admin/administrators");
|
|
}
|
|
else {
|
|
$_SESSION["error"]="utilisateur introuvable.";
|
|
header("Location:/login");
|
|
}
|
|
}
|
|
}
|