|
|
@ -71,25 +71,36 @@ class UserControleur
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function connection(){
|
|
|
|
public function connection(){
|
|
|
|
global $twig; // nécessaire pour utiliser variables globales
|
|
|
|
global $twig; // nécessaire pour utiliser variables globales
|
|
|
|
echo $twig->render('Connection.html');
|
|
|
|
if (AdminModel::isAdmin()) {
|
|
|
|
if (isset($_POST['username']) && isset($_POST['password'])) {
|
|
|
|
$this->listArticle();
|
|
|
|
$this->login();
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
echo $twig->render('Connection.html');
|
|
|
|
|
|
|
|
if (isset($_POST['username']) && isset($_POST['password'])) {
|
|
|
|
|
|
|
|
$this->login();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @throws \Twig\Error\RuntimeError
|
|
|
|
|
|
|
|
* @throws \Twig\Error\SyntaxError
|
|
|
|
|
|
|
|
* @throws \Twig\Error\LoaderError
|
|
|
|
|
|
|
|
* @throws \Exception
|
|
|
|
|
|
|
|
*/
|
|
|
|
public function login(){
|
|
|
|
public function login(){
|
|
|
|
$username = $_POST['username'];
|
|
|
|
$username = $_POST['username'];
|
|
|
|
$password = $_POST['password'];
|
|
|
|
$password = $_POST['password'];
|
|
|
|
|
|
|
|
|
|
|
|
$adminModel = new AdminModel();
|
|
|
|
$adminModel = new AdminModel();
|
|
|
|
$admin = $adminModel->connection($username, $password);
|
|
|
|
$admin = $adminModel->connection($username, $password);
|
|
|
|
|
|
|
|
|
|
|
|
if ($admin != null) {
|
|
|
|
if ($admin != null) {
|
|
|
|
$this->listArticle();
|
|
|
|
$this->listArticle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
unset($_POST['username']);
|
|
|
|
unset($_POST['username']);
|
|
|
|
unset($_POST['passwords']);
|
|
|
|
unset($_POST['passwords']);
|
|
|
|
|
|
|
|
unset($_SESSION['role']);
|
|
|
|
$this->connection();
|
|
|
|
$this->connection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|